Esempio n. 1
0
        private IEnumerable <TEntity> GetAllCached(OptionsFilter options)
        {
            LiteQueryable <TEntity> queryDB = DbContext.Repository.Query <TEntity>();

            if (options.id_like != null)
            {
                foreach (var item in options.id_like)
                {
                    queryDB = queryDB.Where(x => options.id_like.Contains(x.Id));
                }
            }

            if (options._filter != null && options._filter.Count > 0)
            {
                var listPredicate = Filter.ByQueryParams <TEntity>(options);
                foreach (var predicate in listPredicate)
                {
                    queryDB = queryDB.Where(predicate);
                }
            }

            if (options._take != 0)
            {
                queryDB = queryDB.Limit(options._take);
            }

            if (options._skip != 0)
            {
                queryDB = queryDB.Skip(options._skip);
            }

            if (options._page != 0)
            {
                var take = options._take == 0 ? 10 : options._take;
                var page = (options._page - 1) * take;

                queryDB = queryDB.Skip(page).Limit(take);
            }

            if (options._sort != null)
            {
                return(Filter.Sort(options, queryDB.ToList()));
            }

            return(queryDB.ToEnumerable());
        }
Esempio n. 2
0
 public IList <T> ToList()
 {
     return(_query.ToList());
 }