0

i developed an sample application using Entity Framework 4.0. but now i'm gonne developed a real app for a company. where i would like to implement the DAL with Entity framework with generic repository , unit of work and DI container.

please any one suggest me a real example for the framework..

Thanks Rusho

Jayantha Lal Sirisena
  • 21,216
  • 11
  • 71
  • 92
PAryan
  • 51
  • 2
  • 7

1 Answers1

1

Generic repository is nonsense. If you want to use design pattern called Repository you should think about specific repository and aggregate roots.

Generic repository is just a wrapper around ObjectSet / DbSet providing no added value - only additional layer which must be maintained and which makes interaction with EF harder. Also adding repository without clarifying why you want to do that and what it should solve for you is wrong approach - design pattern is a blue print for solving a problem. Not something you should use just because it exists and everybody talks about it.

You can also check these answers where I discuss generic repository and its implications:

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • 1
    I disagree with this. Since the _pattern_ is something you implement yourself, there's nothing wrong with having a generic version, and just making sure you don't implement "All()", and then use that as a base class for others that might have their own specific needs (e.g. a situation when you know "All()" isn't going to overload the database). But if a generic base class avoids code reuse then why discourage it? – devlord Nov 22 '12 at 03:38