public IEnumerable <dynamic> FindPart(FindParam <TEntity> param, Expression <Func <TEntity, dynamic> > fields) { bool isDistinct = param.IsDistinct; param.IsDistinct = false; IQueryable <dynamic> result = FindInner(param).Select(fields); if (isDistinct) { result = result.Distinct(); } return(result); }
private IQueryable <TEntity> FindInner(FindParam <TEntity> param) { IQueryable <TEntity> dbSet = UnitOfWork.GetModel <TEntity>(); if (param.Property != null) { foreach (var expression in param.Property) { dbSet = dbSet.Include(expression); } } if (param.Criteria != null) { dbSet = dbSet.Where(param.Criteria.GetPredicate()); } if (param.OrderByNumber != null) { foreach (var predicate in param.OrderByNumber) { dbSet = dbSet.OrderBy(predicate); } } if (param.Skip != null) { dbSet = dbSet.Skip((int)param.Skip); } if (param.Take != null) { dbSet = dbSet.Take((int)param.Take); } if (param.AsNoTracking) { dbSet = dbSet.AsNoTracking(); } if (param.IsDistinct) { dbSet = dbSet.Distinct(); } return(dbSet); }
public IEnumerable <TEntity> Find(FindParam <TEntity> param) { return(FindInner(param)); }