public MobileLoadResult(LoadResult <T> res) { Code = 0; Message = "Success"; List = res.List; TotalCount = res.TotalCount; }
public static LoadResult <T> LoadWith <T>(this IQueryable <T> q, ListOptions <T> opts) where T : class { LoadResult <T> res = new LoadResult <T>(); ExpressionGenerator <T> gen = new ExpressionGenerator <T>(); if (opts == null) { opts = new ListOptions <T>(); } if (opts.Filters != null) { for (int i = 0; i < opts.Filters.Count; i++) { Expression <Func <T, bool> > e = (Expression <Func <T, bool> >)opts.Filters[i]; q = q.Where(e); } res.TotalCount = q.Count(v => true); } else { res.TotalCount = q.Count(d => true); } if (!string.IsNullOrEmpty(opts.OrderProperty)) { q = gen.SortWith(q, opts.OrderProperty, opts.Direction); } if (opts.Showing > 0) { q = q.Skip(opts.Skip).Take(opts.Showing); } res.List = q.ToList(); return(res); }