public List <TData> GetList <TData>(ISelectSpecification <TEntity, TData> specification)
 {
     return(_context
            .Set <TEntity>()
            .ApplaySelectSpecification(specification)
            .ToList());
 }
 public TData Get <TData>(ISelectSpecification <TEntity, TData> specification)
 {
     return(_context
            .Set <TEntity>()
            .ApplaySelectSpecification(specification)
            .FirstOrDefault());
 }
 public TData SingleOrDefault <TData>(ISelectSpecification <TEntity, TData> specification)
 {
     return(_context
            .Set <TEntity>()
            .AsNoTracking()
            .ApplaySelectSpecification(specification)
            .SingleOrDefault());
 }
Exemple #4
0
 public Task <List <TData> > GetList <TData>(ISelectSpecification <TEntity, TData> specification)
 {
     return(_context
            .Set <TEntity>()
            .AsNoTracking()
            .ApplaySelectSpecification(specification)
            .ToListAsync());
 }
Exemple #5
0
 public Task <TData> FirstOrDefault <TData>(ISelectSpecification <TEntity, TData> specification)
 {
     return(_context
            .Set <TEntity>()
            .AsNoTracking()
            .ApplaySelectSpecification(specification)
            .FirstOrDefaultAsync());
 }
Exemple #6
0
        public static IQueryable <TData> ApplaySelectSpecification <TEntity, TData>(this IQueryable <TEntity> query, ISelectSpecification <TEntity, TData> specification)
            where TEntity : class, IBaseEntity
        {
            if (specification == null)
            {
                throw new ArgumentNullException($"Specification can not be null");
            }

            if (specification.Select == null)
            {
                throw new Exception("Select can not be null");
            }

            query = query.ApplayBaseSpecification(specification);

            return(query.Select(specification.Select));
        }