public async Task <IEnumerable <TEntity> > GetAllAsync(IQuerySettings <TEntity> setting = null) { IQueryable <TEntity> query = _teachersDiaryDbContext.Set <TEntity>(); if (setting != null) { if (setting.IncludePaths != null) { foreach (var path in setting.IncludePaths) { query = query.Include(path); } } if (setting.WhereFilter != null) { query = query.Where(setting.WhereFilter); } if (setting.ReadOnly) { query = query.AsNoTracking(); } } return(await query.ToListAsync()); }
public EntityFrameworkGenericRepository(ITeachersDiaryDbContext teachersDiaryDbContext) { if (teachersDiaryDbContext == null) { throw new ArgumentNullException(nameof(teachersDiaryDbContext)); } _teachersDiaryDbContext = teachersDiaryDbContext; DbSet = _teachersDiaryDbContext.Set <TEntity>(); }