예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public IEnumerable <TEntity> Find(FindParam <TEntity> param)
 {
     return(FindInner(param));
 }