Presented in partnership with
Sponsors
An Introduction to Castle ActiveRecord, or Stop Writing CRUD!
Writing CRUD sucks!
Every day, you are challenged to get more done in less time.
You want to focus on real business value and stop being a plumber.
In the end, it’s about having more time to do what’s really important.
What is the Castle Project? MonoRail ActiveRecord MicroKernel Windsor
What is Castle ActiveRecord? Castle ActiveRecord is an implementation of the ActiveRecord pattern for .NET implemented using Nhibernate.
The Pattern “An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.”
What is Nhibernate? Its purpose is to relieve the developer from a significant amount of relational data persistence-related programming tasks.
Code Walkthrough – The Old Way
The ActiveRecord Way • Very little configuration • Extend from a base class – ActiveRecordBase<T> – ActiveRecordValidationBase<T> • Attributes – [ActiveRecord] – [PrimaryKey] – [Property] – [HasMany] – [BelongsTo]
Code Walkthrough – ActiveRecord
Things to think about • Text columns • Lazy Loading • Web apps require “ isWeb =true” • ActiveWriter
ActiveWriter • Drag & drop design surface • 1-way generation – Partial classes
Lazy Loading ActiveRecord supports lazy loading BUT You should check this link out http://is.gd/71h
Pros and Cons • Pros – Simple, yet powerful – NHibernate behind the scenes and readily available when more power is needed • Cons – Not a good fit for complex schemas or for batch operations.
Contacting me • My Blog: http://mjeaton.net • Email: mjeaton@gmail.com • Twitter: http://twitter.com/mjeaton
References • The Castle Project – http://castleproject.org • Martin Fowler’s ‘Patterns of Enterprise Application Architecture’ – http://www.martinfowler.com/eaaCatalog/ • NHibernate – http://www.hibernate.org
Recommend
More recommend