We use Repository Pattern inside our CSLA BO to extract data access code into a separate class – repository object, because we use interface IRepository to loose couple BO and concrete Repository object and implement “design by contract”, so BO doesn’t care which technology repository is using, either using ADO.net or Linq to SQL, or NHinbernate or Entity Framework .
The benefits of using this model include:
- Loose coupling between BL and DAL
- Easy to switch to different Data Access technology
- Central place to control and switch IOC container
Updated at Feb. 09, 2009:
Found this post about the difference between DAO and Repository pattern. Yes, my model is more similar to DAO, because I was following one Repo/DAO per table rule. In fact, I’m on the progress of switching to the new Csla.ObjectFactory which is a real repository class, or, at lease, can be a repository wrapper, as Ryan did in his example.