The Persistence Ignorant Domain Model James Kovacs
POCO – Plain Old CLR Object No persistence-related code Only business logic public class Customer { public string Name { get; } public Location Address { get; } public IList Orders { get; } public void AddOrder(Order o) {} } What is Persistence Ignorance?
Separation of concerns Single responsibility Loose coupling Testability Re-use Why is Persistence Ignorance Important?
NHibernate and PI No special persistence-related base class No marker or callback interfaces No persistence-related attributes NHibernate domain class: public class Customer { public string Name { get; } public Location Address { get; } public IList Orders { get; } public void AddOrder(Order o) {} }
NHibernate API ConfigurationClass for bootstrapping NHibernate ISessionFactoryFactory for creating sessions ISessionRoughly analogous to a database connection ITransactionAbstracts underlying transaction semantics IQueryString-based query API ICriteriaObject-based query API
Resources NHibernate ( NHibernate in Action by Pierre Henri Kuaté, et al. NHibernate Plugin ( Castle Active Record ( Active Writer ( Domain-Driven Design by Eric Evans Applying Domain-Driven Design and Patterns by Jimmy Nilsson
Questions James Kovacs