/// <summary> /// Order <see cref="IOrderedEnumerable{TSource}"/> then by /// </summary> /// <typeparam name="TSource"></typeparam> /// <param name="source"></param> /// <param name="sortColum">name of the column to sort on</param> /// <param name="sortDirection">the order by which to sort</param> /// <returns></returns> public static IOrderedEnumerable <TSource> ThenBy <TSource>(this IOrderedEnumerable <TSource> source, string sortColum, string sortDirection) { if (source == null) { throw new ArgumentNullException("source"); } return(OrderByInternal.EnumerableOrderThenBy(source, new OrderItem { SortColum = sortColum, OrderDirection = Orderby.GetOrderDirection(sortDirection) })); }
/// <summary> /// Order <see cref="IOrderedQueryable{TSource}"/> then by /// </summary> /// <typeparam name="TSource"></typeparam> /// <param name="source"></param> /// <param name="sortColum">name of the column to sort on</param> /// <param name="isDescending">Is the order direction descending</param> /// <returns></returns> public static IOrderedQueryable <TSource> ThenBy <TSource>(this IOrderedQueryable <TSource> source, string sortColum, bool isDescending) { if (source == null) { throw new ArgumentNullException("source"); } return(OrderByInternal.QueryableOrderThenBy(source, new OrderItem { SortColum = sortColum, OrderDirection = Orderby.GetOrderDirection(isDescending) })); }
/// <summary> /// Order an <see cref="IQueryable{TSource}"/> /// </summary> /// <typeparam name="TSource"></typeparam> /// <param name="source"></param> /// <param name="sortColum">name of the column to sort on</param> /// <param name="sortDirection">the order by which to sort</param> /// <returns></returns> public static IOrderedQueryable <TSource> OrderBy <TSource>(this IQueryable <TSource> source, string sortColum, string sortDirection) { if (source == null) { throw new ArgumentNullException("source"); } return(OrderByInternal.QueryableOrder(source, new OrderItem { SortColum = sortColum, OrderDirection = Orderby.GetOrderDirection(sortDirection) }, out _)); }
/// <summary> /// Order <see cref="IOrderedQueryable{TSource}"/> then by /// </summary> /// <typeparam name="TSource"></typeparam> /// <typeparam name="TKey"></typeparam> /// <param name="source"></param> /// <param name="sortColum">Comma or semicolumn seperated string expression of the colume and direction. Directon is not mandatory, if not pressend then it will be ascending</param> /// <param name="isDescending">Is the order direction descending</param> /// <param name="comparer"><see cref="IComparer{TKey}" /></param> /// <returns></returns> public static IOrderedQueryable <TSource> ThenBy <TSource, TKey>(this IOrderedQueryable <TSource> source, string sortColum, bool isDescending, IComparer <TKey> comparer) { if (source == null) { throw new ArgumentNullException("source"); } if (string.IsNullOrWhiteSpace(sortColum)) { throw new ArgumentException("Input cannot be null or empty", "sortColum"); } return(OrderByInternal.QueryableOrderThenBy(source, new OrderItem <TKey> { SortColum = sortColum, OrderDirection = Orderby.GetOrderDirection(isDescending), Comparer = comparer })); }
/// <summary> /// Order an <see cref="IEnumerable{TSource}"/> /// </summary> /// <typeparam name="TSource"></typeparam> /// <param name="source"></param> /// <param name="sortColum">name of the column to sort on</param> /// <param name="isDescending">Is the order direction descending</param> /// <returns></returns> public static IOrderedEnumerable <TSource> OrderBy <TSource>(this IEnumerable <TSource> source, string sortColum, bool isDescending) { if (source == null) { throw new ArgumentNullException("source"); } if (string.IsNullOrWhiteSpace(sortColum)) { throw new ArgumentException("Input cannot be null or empty", "sortColum"); } return(OrderByInternal.EnumerableOrder(source, new OrderItem { SortColum = sortColum, OrderDirection = Orderby.GetOrderDirection(isDescending) }, out _)); }