/// <summary> /// Extension method applies subsequent ordering to the IOrderedQueryable reference /// </summary> /// <typeparam name="T"> ENTITY type </typeparam> /// <param name="query"> IOrderedQueryable reference - usually obtained as a result of calling .OrderBy() or OrderByDescending() </param> /// <param name="thenOrderBy"> array of subsequent ordering to be applied </param> /// <returns> ordered queryable instance </returns> public static IOrderedQueryable <T> ThenOrderBy <T>(this IOrderedQueryable <T> query, ThenOrderBy <T, object>[] thenOrderBy) { if (thenOrderBy != null) { foreach (ThenOrderBy <T, object> @by in thenOrderBy) { query = query.Order(@by.thenBy, @by.direction, thenBy: true); } } return(query); }
public static IOrderedQueryable <T> ThenByDescending <T>(this IOrderedQueryable <T> source, string property) { return(source.Order(property, nameof(Enumerable.ThenByDescending))); }
/// <summary> /// Extension method applies the <paramref name="orderBy"/> using the specified <paramref name="direction"/> /// </summary> /// <typeparam name="T"> ENTITY type </typeparam> /// <param name="query"> IOrderedQueryable reference - usually obtained as a result of calling .OrderBy() or OrderByDescending() </param> /// <param name="orderBy"> order by column </param> /// <param name="direction"> order direction </param> /// <returns> ordered queryable instance </returns> public static IOrderedQueryable <T> ThenOrderBy <T>(this IOrderedQueryable <T> query, Expression <Func <T, object> > orderBy, SortDirection direction) { return(query.Order(orderBy, direction, thenBy: true)); }