NHibernate视图使用
2012-05-28 10:47 java ee spring 阅读(169) 评论(0) 编辑 收藏 举报使用视图,其他和使用表都一样,就是持久化类的get属性设置成private如下:
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; } } }
映射文件:
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DomainModel" namespace="DomainModel"> <class name="DomainModel.Entities.CustomerView,DomainModel" table="viewCustomer" mutable="false" > <id name="CustomerId" column="CustomerId" type="Int32"> <generator class="native" /> </id> <property name="Firstname" column="Firstname" type="string" /> <property name="Lastname" column="Lastname" type="string" /> <property name="OrderId" column="OrderId" type="Int32" /> <property name="OrderDate" column="OrderDate" type="DateTime" /> </class> </hibernate-mapping>
其他查询都是一样的。