public TEntity FindSingleEager(Expression <Func <TEntity, bool> > predicate, List <string> paths) { var query = _context.Set <TEntity>().Where(predicate); foreach (string path in paths) { query = query.Include(path); } return(query.SingleOrDefault <TEntity>()); }
public async Task <List <TEntity> > GetFilteredEntityList(string name, string lastName) { DbSet <TEntity> dbSet = _dbContext.Set <TEntity>(); IQueryable <TEntity> entityListQueryable = dbSet; if (!string.IsNullOrEmpty(name)) { entityListQueryable = entityListQueryable.Where("Name == @0", name); } if (!string.IsNullOrEmpty(lastName)) { entityListQueryable = entityListQueryable.Where("LastName == @0", lastName); } return(await entityListQueryable.ToListAsync()); }
public Repository(YourDbContext dbContext) { _dbContext = dbContext; _dbSet = _dbContext.Set <TEntity>(); }