public static IQueryable <TSource> OrderBy <TSource>(this IQueryable <TSource> query, string key, bool ascending = true)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return(query);
            }

            var lambda = (dynamic)CreateExpression(typeof(TSource), key);

            return(ascending
                ? Queryable.OrderBy(query, lambda)
                : Queryable.OrderByDescending(query, lambda));
        }
示例#2
0
            public static IOrderedQueryable <T> OrderBy(IQueryable <T> queryable, string propertyName, bool desc)
            {
                dynamic keySelector = GetLambdaExpression(propertyName);

                return(desc ? Queryable.OrderByDescending(queryable, keySelector) : Queryable.OrderBy(queryable, keySelector));
            }
示例#3
0
            public static IQueryable <T> OrderBy(IQueryable <T> queryable, string propertyName)
            {
                dynamic keySelector = GetLambdaExpression(propertyName);

                return(Queryable.OrderBy(queryable, keySelector));
            }
示例#4
0
 public virtual IOrderedQueryable <TSource> OrderBy <TSource, TKey>(IQueryable <TSource> source, Expression <Func <TSource, TKey> > keySelector, IComparer <TKey> comparer)
 {
     return(Queryable.OrderBy <TSource, TKey>(source, keySelector, comparer));
 }
 /// <inheritdoc cref="Queryable.OrderBy{TSource, TKey}(IQueryable{TSource}, Expression{Func{TSource, TKey}}, IComparer{TKey})" />
 public static IOrderedQueryableAndAsyncQueryable <TSource> OrderBy <TSource, TKey>(this IQueryableAndAsyncQueryable <TSource> source, Expression <Func <TSource, TKey> > keySelector, IComparer <TKey> comparer)
 {
     return((IOrderedQueryableAndAsyncQueryable <TSource>)Queryable.OrderBy <TSource, TKey>(source, keySelector, comparer));
 }
 public static IOrderedQueryable <TSource> OrderBy(IQueryable <TSource> source, string propertyName) => Queryable.OrderBy(source, (dynamic)CreateLambdaExpression(propertyName));
示例#7
0
 public static IOrderedAsyncQueryable <TSource> OrderBy <TSource, TKey>(this IAsyncQueryable <TSource> source, Expression <Func <TSource, TKey> > keySelector)
 {
     return((IOrderedAsyncQueryable <TSource>)Queryable.OrderBy(source, keySelector));
 }