Fluent Nhibernate Mapping for Sql Views

Views are mapped the same way tables are mapped except that you should put Readonly() in the mapping to prevent accidently writing to it. Example:

public class FeaturedCompanyMap : ClassMap<FeaturedCompany>
{
    public FeaturedCompanyMap ()
    {
       Table("FeaturedCompanies");
       ReadOnly();

       Id(x => x.Id);
       Map(x => x.Name);
       Map(x => x.Count);
    }
}
posted @ 2015-03-19 10:24  awp110  阅读(90)  评论(0编辑  收藏  举报