| 13 | } |
| 14 | |
| 15 | public virtual async Task<IEnumerable<TEntity>> Get(Expression<Func<TEntity, bool>>? filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>>? orderBy = null, string includeProperties = "") |
| 16 | { |
| 17 | IQueryable<TEntity> query = dbSet; |
| 18 | if (filter != null) |
| 19 | { |
| 20 | query = query.Where(filter); |
| 21 | } |
| 22 | foreach (var includeProperty in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) |
| 23 | { |
| 24 | query = query.Include(includeProperty); |
| 25 | } |
| 26 | if (orderBy != null) |
| 27 | { |
| 28 | return await orderBy(query).ToListAsync(); |
| 29 | } |
| 30 | return await query.ToListAsync(); |
| 31 | } |
| 32 | |
| 33 | public virtual async Task<TEntity?> GetById(Guid id) |
| 34 | { |