public Mvc.Pager.PagedList <object> GetList(Func <IQueryable <TEntity>, List <object> > selector, Core.Specifications.ISpecification <TEntity> spec, string orderByString, string order, int PageIndex = 1, int PageSize = 24) { var query = order.Trim().ToLower().Equals("desc") ? (this.DbSet.Where(spec.GetExpression()).OrderBy(orderByString, true)) : (this.DbSet.Where(spec.GetExpression()).OrderBy(orderByString)); var result = query.Skip((PageIndex - 1) * PageSize).Take(PageSize); var list = new Mvc.Pager.PagedList <object>(selector(result), PageIndex, PageSize, query.Count()); return(list); #region reflection //PropertyInfo property = typeof(TEntity).GetProperty(orderByString); //string type = property.PropertyType.FullName; //Type generic = typeof(CreateExpression<,>); //Type[] typeArgs2 = { typeof(TEntity), Type.GetType(type) }; //generic = generic.MakeGenericType(typeArgs2); //var dic = Activator.CreateInstance(generic); //MethodInfo mi = dic.GetType().GetMethod("GetExpressionByStringColumn"); //Expression<Func<TEntity, int>> result = mi.Invoke(null, new object[] { orderByString }) as Expression<Func<TEntity, int>>; #endregion }
public Pager.PagedList <object> GetList(Func <IQueryable <TEntity>, List <object> > selector, Core.Specifications.ISpecification <TEntity> spec , Dictionary <string, bool> paramNames , int PageIndex = 1 , int PageSize = 24) { var query = this.DbSet.Where(spec.GetExpression()).OrderBy(paramNames); var result = query.Skip((PageIndex - 1) * PageSize).Take(PageSize); var list = new Mvc.Pager.PagedList <object>(selector(result), PageIndex, PageSize, query.Count()); return(list); }
public TEntity GetEntity(Core.Specifications.ISpecification <TEntity> spec) { return(GetEntity(spec.GetExpression())); }