Suggested Videos
Part 1 - ASP.NET Core razor pages introduction | Text | Slides
Part 2 - ASP.NET core 3.0 project file | Text | Slides
Part 3 - Layout view in razor pages project | Text | Slides
In this video we will discuss, creating a reusable Models class library project. This project can then be reused with a razor pages web application, windows application, web api etc. It works cross platform.
Creating .Net Standard Class Library Project
In the Solution Explorer, right click on the solution and select Add - New Project.
In the Add a new project dialog, type Class Library. You will see several different class library projects. We will discuss the differences and when to use one over the other in our upcoming videos. The one we want is .NET Standard Class Library.
On the next screen provide a name for the project. Since this project is going to contain the models, I am going to name it RazorPagesTutorial.Models.
Finally, click Create.
Creating the models
In this project, we will be performing CRUD (i.e Create, Read, Update and Delete) operations against Employees. So we need an Employee class and Dept enum.
Dept Enum
Employee Class
Next, we need to create services that retrieve data from an underlying data source such as a SQL Server database. We will create these services also in a separate reusable .Net Standard class library project.
Part 1 - ASP.NET Core razor pages introduction | Text | Slides
Part 2 - ASP.NET core 3.0 project file | Text | Slides
Part 3 - Layout view in razor pages project | Text | Slides
In this video we will discuss, creating a reusable Models class library project. This project can then be reused with a razor pages web application, windows application, web api etc. It works cross platform.
Creating .Net Standard Class Library Project
In the Solution Explorer, right click on the solution and select Add - New Project.
In the Add a new project dialog, type Class Library. You will see several different class library projects. We will discuss the differences and when to use one over the other in our upcoming videos. The one we want is .NET Standard Class Library.
On the next screen provide a name for the project. Since this project is going to contain the models, I am going to name it RazorPagesTutorial.Models.
Finally, click Create.
Creating the models
In this project, we will be performing CRUD (i.e Create, Read, Update and Delete) operations against Employees. So we need an Employee class and Dept enum.
Dept Enum
namespace RazorPagesTutorial.Models
{
public enum Dept
{
None,
HR,
IT,
Payroll
}
}
{
public enum Dept
{
None,
HR,
IT,
Payroll
}
}
Employee Class
namespace RazorPagesTutorial.Models
{
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string PhotoPath { get; set; }
public Dept? Department { get; set; }
}
}
{
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string PhotoPath { get; set; }
public Dept? Department { get; set; }
}
}
Next, we need to create services that retrieve data from an underlying data source such as a SQL Server database. We will create these services also in a separate reusable .Net Standard class library project.
No comments:
Post a Comment
It would be great if you can help share these free resources