one IRepository (generic one) and one implementation of that with a method that takes a linQ in parameter
public virtual IEnumerable<TEntity> Get(
Expression<Func<TEntity, bool>> filter = null,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
string includeProperties = ""
)
in this case I shouldn't write a separate repository for each model.
OR OR
I should write a separate repository for each model and put methods like GetTopUser() or GetInActiveUser() and write query in that methods in repository?
Generic. Approach is the best approach remember the SOLID principle Single responsibility for a class if you are repeating queries then you are doing Strategy pattern instead of Repository pattern
Обсуждают сегодня