16 lines
706 B
C#
16 lines
706 B
C#
using System.Linq.Expressions;
|
|
using ApplicationHub.Domain.Contracts;
|
|
using AutoMapper;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ApplicationHub.Data.EF.Utils;
|
|
|
|
public class BaseRepository<TModel, TEntity>(DbSet<TEntity> dbSet, IMapper mapper) : IRepository<TModel> where TEntity : class
|
|
{
|
|
public IEnumerable<TModel> Find(Expression<Func<TModel, bool>>? where = null, int? limit = null, int? offset = null, List<KeyValuePair<Expression<Func<TModel, bool>>, OrderDirection>>? order = null)
|
|
{
|
|
var resolver = new QueryResolver<TModel, TEntity>();
|
|
var result = resolver.Find(dbSet, where, limit, offset, order).ToList();
|
|
return mapper.Map<List<TModel>>(result);
|
|
}
|
|
} |