ActiveRecord and support for DetachedQuery
This weekend I wrote the classes necessaries to support IDetachedQuery with ActiveRecord. DetachedQuery it’s not available yet at any version of NHibernate, you can find it only in uNHAddIns and at the SVN of NHibernate.
I add a project to uNHAddIns: uNHAddIns.ActiveRecord. This consist in the classical classes for ActiveRecord with support for IDetachedQuery.
If we want support for IDetachedQuery using ActiveRecord you must this clases:
- ActiveRecordBase
- ActiveRecordBase<T>
- ActiveRecordValidationBase
- and ActiveRecordValidationBase<T>
Now you will able to do somethings like this:
Customer[] customers = Customer.FindAll(new DetachedQuery("from Customer Order By Name"));
The new methods for ActiveRecordBase and ActiveRecordValidationBase are:
-
public static bool Exists(Type targetType, IDetachedQuery detachedQuery);
-
public static Array FindAll(Type targetType, IDetachedQuery detachedQuery);
-
public static object FindFirst(Type targetType, IDetachedQuery detachedQuery);
-
public static object FindOne(Type targetType, IDetachedQuery detachedQuery);
-
public static Array SlicedFindAll(Type targetType, int firstResult, int maxResults, IDetachedQuery detachedQuery);
And the new methods for ActiveRecordBase<T> and ActiveRecordValidationBase<T> are:
-
public static bool Exists(IDetachedQuery detachedQuery);
-
public static T[] FindAll(IDetachedQuery detachedQuery);
-
public static T FindFirst(IDetachedQuery detachedQuery);
-
public static T FindOne(IDetachedQuery detachedQuery);
-
public static T[] SlicedFindAll(int firstResult, int maxResults, IDetachedQuery detachedQuery);
This implementation no hide any feature of ActiveRecord base classes, it’s a extension for IDetachedQuery support.
Requeriments
This classes are provided in the assembly uNHAddIns.ActiveRecord.dll. And this assembly require the main assembly of the project: uNHAddIns.dll.
Downloads here
Wiki entry
tweets
Recent Posts
- How To: Configure Access Control Service on Windows Azure
- Installing Windows 8 Consumer Preview with VMWare Workstation 8
- Authorizable content with Razor
- NHibernate Validator on GitHub
- NHibernate Validator 1.3.1 GA
- NHibernate Validator 1.2 Beta3 released
- NHibernate Validator 1.2 Beta2 released
- jqGrid + Linq + Asp.Net MVC example
- Asp.net MVC: Testing a custom Authorize filters
- NHibernate Validator Quickstart
Recent Comments
- Dario on Installing Windows 8 Consumer Preview with VMWare Workstation 8
- Steve C on Installing Windows 8 Consumer Preview with VMWare Workstation 8
- Quang on StatelessSession: NHibernate without first-level cache
- Luis Fernando on NHibernate Validator 1.3.1 GA
- Daniel on NHibernate – Bulk Manipulation with SQL Native





Pingback: ActiveRecord con soporte para DetachedQuery at Espacio de Dario Quintana
Pingback: ActiveRecord moving to NHibernate 2 at Dario Quintana