- Http://sadin.dev
- https://sadin.dev
- in/EnKamran
- c/MrSadin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So its time to working with Views | |
At first create Views folder : mkdir Views | |
Create Home and Shared folder : mkdir Views\Home mkdir Views\Shared | |
Creating files : | |
echo.>Views\_ViewImports.cshtml | |
echo.>Views\_ViewStart.cshtml | |
echo.>Views\Shared\_Layout.cshtml | |
echo.>Views\Home\Index.cshtml | |
Open Startup.cs and add this line to Configure method : | |
app.UseStaticFiles(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create directory : | |
mkdir DirectoryName | |
mkdir MrSadin | |
2. Navigate to directory : | |
cd DirectoryName (Or Path) | |
cd MrSadin | |
3. Delete Empty Directory : (Attention, directory should be empty) | |
rmdir DirectoryName | |
rmdir MrSadin | |
4. Delete directory that contains some files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First of all install vscode-nuget-package-manager Extension. | |
Open .cspro file | |
Press Ctrl + Shift + P and type >NuGet Package MAnager: Add Package | |
Type Microsoft.EntityFrameworkCore.SqlServer | |
use dotnet restore | |
Create database 'MyDatabase' and a table called MyModels with 3 fields (Id, FullName,Email) | |
Add 'Models' folder and 'MyDbContext.cs' and 'MyModel.cs' files in it | |
Open MyModel.cs and add this codes : | |
using Microsoft.EntityFrameworkCore; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For publish .net core project open terminal (command) and navigate to project directory | |
Then type dotnet publish -o /PublishFolderPath |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
// Add framework services. | |
services.AddDbContext<ApplicationDbContext>(options => | |
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); | |
services.AddIdentity<ApplicationUser, IdentityRole>() | |
.AddEntityFrameworkStores<ApplicationDbContext>() | |
.AddDefaultTokenProviders(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First of all you should install pre requirements: | |
Install Dot Net Core (http://dot.net/Core) | |
Install Visual Studio Code | |
1. Now run Visual Studio Code | |
2. Press Ctrl + ` (or from View menu select Integrated Terminal) | |
3. Navigate to folder that you want to create project in it. | |
4. run this command : dotnet new web (this will create project files in current folder) | |
5. Open Startup.cs file and edit it : | |
5.1 Add 'services.AddMvc();' to ConfigureServices void | |
5.2 Add route to Configure void : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Select query | |
//Table name : MyTable | |
//In this table i have one field called : PropertyName | |
using(var db = new MyDbContext()) | |
{ | |
var myData = db.MyTableName.SqlQuery("SELECT * From MyTableName").ToList(); | |
foreach(var data in myData) | |
{ | |
Response.Write(data.PropertyName + "<br/>"); | |
} |
NewerOlder