public static IQueryable <T> Order(IQueryable <T> querable, OrderExtention orderExtention) { if (orderExtention == null || string.IsNullOrWhiteSpace(orderExtention.Property)) { return(querable); } if (querable == null || querable.Count() <= 0) { return(null); } var property = orderExtention.Property; if (orderExtention.OrderBy == OrderBy.Ascending) { var prop = typeof(T).GetProperty(property); querable = querable.OrderBy(x => prop.GetValue(x, null)).ToList().AsQueryable(); } else { var prop = typeof(T).GetProperty(property); querable = querable.OrderByDescending(x => prop.GetValue(x, null)).ToList().AsQueryable(); } return(querable); }
public PagedResult <TEntity> FindByIncludeOrderByPagination(int page, int pageSize, Func <TEntity, bool> predicate, OrderExtention orderExtention, params Expression <Func <TEntity, object> >[] includes) { return(OrderList <TEntity> .Order(table.IncludeMultiple(includes).Where(predicate).AsQueryable(), orderExtention).GetPaged(page, pageSize)); }
public PagedResult <TEntity> FilterOrderByPagination(Func <TEntity, bool> predicate, OrderExtention orderExtention, int page, int pageSize) { return(OrderList <TEntity> .Order(table.Where(predicate).AsQueryable(), orderExtention).GetPaged(page, pageSize)); }
public IQueryable <TEntity> FindOrderByInclude(Func <TEntity, bool> predicate, OrderExtention orderExtention, params Expression <Func <TEntity, object> >[] includes) { return(OrderList <TEntity> .Order(table.IncludeMultiple(includes).Where(predicate).AsQueryable(), orderExtention)); }
/// <summary> /// Never use this function want if db table to big it slow down everything /// Instead use <see cref="FilterByPagination(Func<TEntity, bool>, int, int)" /> /// </summary> /// <returns>List of ALL elements in the table</returns> public IQueryable <TEntity> FilterOrder(Func <TEntity, bool> predicate, OrderExtention orderExtention) { return(OrderList <TEntity> .Order(table.Where(predicate).AsQueryable(), orderExtention)); }