views:

161

answers:

1

I am playing around with Castle ActiveRecord and noticed that the download included the file, Castle.ActiveRecord.Linq.dll. I haven't found any documentation for using Linq with ActiveRecord, only some old blog posts.

What is the usage pattern? Is Castle.ActiveRecord.Linq ready for production use?

+5  A: 

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.

Mauricio Scheffer
I edited your answer so I could upvote it. It wouldn't let me upvote until an edit, for some reason.
Ronnie Overby