Using Both (Extend & Override)
You’re not limited to just one approach—you can combine overriding existing methods and adding new ones in a single custom repository class.
This gives you maximum flexibility:
Override methods to change or enhance built-in repository behavior.
Extend by introducing brand new methods tailored to your project’s unique requirements.
For example, you might override GetListAsync to add caching or custom filtering logic, while also introducing a brand new method like FindByDepartmentId.
This is the real power of REN.Kit’s repository design: your data layer can be as standard or as custom as you want.
Pro Tip:
Just inherit from the base repository (like RENRepository<TEntity>), override any method you want, and add your own new methods—all in the same class!
How to Use Both? (Override + Extend)
1. Create a New Interface for Your Custom Methods
public interface IExtendedRENRepository<TEntity> : IRENRepository<TEntity>
where TEntity : class
{
void AdditionalMethod();
}This interface introduces your new method(s) while keeping all defaults.
2. Implement Your Custom Repository
3. Register Your Custom Implementation
Since you’re introducing a new interface and class, register both:
Reminder:
Always obtain repositories via Unit of Work! Do not inject repositories directly—call them through your UoW instance to ensure transactional consistency.
4. Use Your Custom Repository in Action
Last updated