How to use Linq with Castle ActiveRecord

安稳与你 提交于 2019-11-30 10:03:01

Yes, Castle.ActiveRecord.Linq is production ready. It's included in the latest ActiveRecord release. The actual Linq provider is implemented in NHibernate.Linq.dll, the ActiveRecord Linq dll is a thin pass-through layer. There are basically two ways to use it:

  1. Make your entities inherit from ActiveRecordLinqBase<T>, then to query:

    var blogs = (from b in Blog.Queryable select b).ToList();
    
  2. Use ActiveRecordLinq.AsQueryable<T>, e.g.:

    var blogs = (from b in ActiveRecordLinq.AsQueryable<Blog>() select b).ToList();
    

Look at the tests for some sample code.

UPDATE: as of ActiveRecord 3.0 beta, Linq is integrated into Castle.ActiveRecord.dll, and NHibernate.Linq.dll is no more (integrated into NHibernate.dll as of NHibernate 3)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!