The contents of this section
Introduced
1. Persistence class
2. Mapping file
3. Test
Conclusion
Introduced
In database operations, in addition to table operations, as well as views, stored procedures, and other operations, this article and the next article to learn about these things. In this article we'll learn how to use views in nhibernate. First, we set up a database named Viewcustomer view, select CustomerID, Firstname, Lastname, OrderId, OrderDate items.
Let's write the Persistence class and mapping for this view in turn.
1. Persistence class
Like the tables in the persisted database, we need to persist the view to define each property in the views, because the view is read-only, so here we simply set the setter of the property to private access. The following are specific practices:
Create a new CustomerView.cs class in the Entities folder of the project Domainmodel layer, writing the following code:
namespace DomainModel.Entities
{
public class CustomerView
{
public virtual int CustomerId { get; private set; }
public virtual string Firstname { get; private set; }
public virtual string Lastname { get; private set; }
public virtual int OrderId { get; private set; }
public virtual DateTime OrderDate { get; private set; }
}
}