ActiveRecord is a well-known pattern described in Patterns of Enterprise Application Architecture
. Basically all static methods act on the whole set of records, while instances represents each row.
What's Castle ActiveRecord?
Castle ActiveRecord is an implementation of the ActiveRecord Pattern inspired by Rails' ActiveRecord
, which relies on NHibernate to perform the actual mapping (no, we don't suffer from Not-invented-here anti-pattern).
How does it differ from pure NHibernate usage?
Castle ActiveRecord was built on top of NHibernate. It offers:
- Fast development (it handles the mapping and infers as much as it can so you dont have to dig into documentation or deal with tons of xmls everytime something changes on your schema)
- Predefined common methods like Create, Update, Save, Delete
- Easy to implement method like Find, FindAll, FindByName...
- Session and transaction scopes that abstracts the ISession and translates them to a more natural idiom
By using pure NHibernate, you have more control over more complex mappings. But using ActiveRecord is a guarantee to boost your productivity.
If you know NHibernate, great. ActiveRecord can give you an ISession instance whenever you want.