GenericRepositorySimple
kandi X-RAY | GenericRepositorySimple Summary
kandi X-RAY | GenericRepositorySimple Summary
GenericRepositorySimple
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of GenericRepositorySimple
GenericRepositorySimple Key Features
GenericRepositorySimple Examples and Code Snippets
Community Discussions
Trending Discussions on GenericRepositorySimple
QUESTION
I found an example of Generic Repository which is based on Entity Framework and trying to understand how to automatically resolve repositories by the same interface and entity type.
The link above leads to the repo where you can see the following approach:
...ANSWER
Answered 2018-Jun-15 at 14:12As mentioned in the comments, avoid reinventing the wheel. If you are using any full ORM (the Entity Framework here), it itself serves as Repository as well as UoW. So, using ORM itself inline and bypassing both Repository and UoW is most recommended. Following are some good read:
http://www.primaryobjects.com/2010/03/17/using-the-nhibernate-repository-pattern-in-c-asp-net/
But, in some cases, you may still want to implement Repository. This allows you injecting the repository in your code making other part of the code testable. Even in that case, avoid using Generic Repository. It is considered an anti-pattern.
In that case, implement concrete repositories per Aggregate Root. Avoid Generic Repository OR just use it as base class for all your concrete repositories. More explanation could be found in this and this and this answers.
Your linked GitHub sample code looks good interface for Generic Base Repository class. Note that it exposes IQueryable GetAll();
. If implemented in base class, this should be fine. Never return IQueryable
from your concrete repositories. It violates basic purpose of Repository Pattern.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install GenericRepositorySimple
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page