Question

This is concerning an enterprise application with a very generic database (all objects are identified using data in the database and internationalized/globalized/localized).

  • Make a model for Repository pattern, then make (generate 1:1) another model for DB access (LINQ2SQL or EF) and use the later as repository model data access layer?
  • Just use L2S/EF/NHibernate model directly, mapping model to DB and opening persistence layer?

Will this dual model idea (repository pattern) popup problems making dynamic stackable LINQ search queries possible when using L2S/EF model directly in a dual model environment?

Please advise.

Was it helpful?

Solution

As long as you are exposing IQueryable objects in your repository, you should have no problem stacking queries in the manner you suggest.

I would be cautious about using Entity Framework for this, since lazy loading is not supported in the way you might expect. Linq to SQL will handle lazy loading without problems.

For more information about lazy loading in the Entity Framework, see:
http://www.singingeels.com/Articles/Entity_Framework_and_Lazy_Loading.aspx

OTHER TIPS

Take a look at sharp architecture.

Regarding returning IQueryable from your repository objects, it is my opinion that doing such blurs a proper separation of concerns in your application. I'm all for working with IQueryable within your data access layer but once you start returning objects as IQueryable you provide the opportunity for your controllers and/or views to start meddling with data access. Such may even negatively impact the testability of your application as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top