ASP.NET Core - EJ2

Upgrade Guide User Guide Demos Support Forums Download
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class QueryableExtensions - ASP.NETCore-EJ2 API Reference | Syncfusion

    Show / Hide Table of Contents

    Class QueryableExtensions

    Provides extension methods for Queryable source.

    var fonts = FontFamily.Families.AsQueryable();

    We would normally write Expressions as,

    var names = new string[] {"Tony", "Al",
    "Sean", "Elia"}.AsQueryable();
    names.OrderBy(n=>n);

    This would sort the names based on alphabetical order. Like so, the Queryable extensions are a set of extension methods that define functions which will generate expressions based on the supplied values to the functions.

    Inheritance
    System.Object
    QueryableExtensions
    Namespace: Syncfusion.EJ2.Linq
    Assembly: Syncfusion.EJ2.dll
    Syntax
    public static class QueryableExtensions : Object

    Methods

    AndAlsoPredicate(Expression, Expression)

    Declaration
    public static BinaryExpression AndAlsoPredicate(this Expression expr1, Expression expr2)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression expr1
    System.Linq.Expressions.Expression expr2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    AndPredicate(Expression, Expression)

    Generates an AND binary expression for the given Binary expressions.

    Declaration
    public static BinaryExpression AndPredicate(this Expression expr1, Expression expr2)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression expr1
    System.Linq.Expressions.Expression expr2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    Average(IQueryable, String)

    Declaration
    public static object Average(this IQueryable source, string propertyName)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    Returns
    Type Description
    System.Object

    Average(IQueryable, String, Expression<Func<String, Object, Object>>, Expression<Func<String, Object, Object>>)

    Declaration
    public static object Average(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc, Expression<Func<string, object, object>> typeFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> typeFunc
    Returns
    Type Description
    System.Object

    Average(IQueryable, String, Type)

    Declaration
    public static object Average(this IQueryable source, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Type sourceType
    Returns
    Type Description
    System.Object

    Count(IQueryable)

    Declaration
    public static int Count(this IQueryable source)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    Returns
    Type Description
    System.Int32

    ElementAt(IQueryable, Int32)

    Declaration
    public static object ElementAt(this IQueryable source, int index)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Int32 index
    Returns
    Type Description
    System.Object

    ElementAt(IQueryable, Int32, Type)

    Declaration
    public static object ElementAt(this IQueryable source, int index, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Int32 index
    System.Type sourceType
    Returns
    Type Description
    System.Object

    ElementAtOrDefault(IQueryable, Int32)

    Declaration
    public static object ElementAtOrDefault(this IQueryable source, int index)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Int32 index
    Returns
    Type Description
    System.Object

    ElementAtOrDefault(IQueryable, Int32, Type)

    Declaration
    public static object ElementAtOrDefault(this IQueryable source, int index, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Int32 index
    System.Type sourceType
    Returns
    Type Description
    System.Object

    Equal(ParameterExpression, String, Object)

    Declaration
    public static Expression Equal(this ParameterExpression paramExpression, string propertyName, object value)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    Returns
    Type Description
    System.Linq.Expressions.Expression

    Equal(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)

    Declaration
    public static Expression Equal(this ParameterExpression paramExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    System.Type elementType
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.Expressions.Expression

    Equal(ParameterExpression, String, String)

    Declaration
    public static BinaryExpression Equal(this ParameterExpression paramExpression, string propertyName, string propertyName2)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.String propertyName2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    GetExpression(ParameterExpression, String)

    Declaration
    public static Expression GetExpression(this ParameterExpression paramExpression, string propertyName)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    Returns
    Type Description
    System.Linq.Expressions.Expression

    GetObjectType(IQueryable)

    Declaration
    public static Type GetObjectType(this IQueryable source)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    Returns
    Type Description
    System.Type

    GetValueExpression(ParameterExpression, String, Type)

    Generate expression from simple and complex property

    Declaration
    public static Expression GetValueExpression(this ParameterExpression paramExpression, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Type sourceType
    Returns
    Type Description
    System.Linq.Expressions.Expression

    GreaterThan(ParameterExpression, String, Object)

    Declaration
    public static BinaryExpression GreaterThan(this ParameterExpression paramExpression, string propertyName, object value)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    GreaterThan(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)

    Declaration
    public static Expression GreaterThan(this ParameterExpression paramExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    System.Type elementType
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.Expressions.Expression

    GreaterThan(ParameterExpression, String, String)

    Declaration
    public static BinaryExpression GreaterThan(this ParameterExpression paramExpression, string propertyName, string propertyName2)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.String propertyName2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    GreaterThanOrEqual(ParameterExpression, String, Object)

    Declaration
    public static BinaryExpression GreaterThanOrEqual(this ParameterExpression paramExpression, string propertyName, object value)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    GreaterThanOrEqual(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)

    Declaration
    public static Expression GreaterThanOrEqual(this ParameterExpression paramExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    System.Type elementType
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.Expressions.Expression

    GreaterThanOrEqual(ParameterExpression, String, String)

    Declaration
    public static BinaryExpression GreaterThanOrEqual(this ParameterExpression paramExpression, string propertyName, string propertyName2)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.String propertyName2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    GroupByMany(IEnumerable, Type, List<SortDescription>, Dictionary<String, IComparer<Object>>, Func<String, Expression>, String[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany(this IEnumerable source, Type sourceType, List<SortDescription> sortFields, Dictionary<string, IComparer<object>> sortComparers, Func<string, Expression> GetExpressionFunc, params string[] properties)
    Parameters
    Type Name Description
    System.Collections.IEnumerable source
    System.Type sourceType
    System.Collections.Generic.List<SortDescription> sortFields
    System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.IComparer<System.Object>> sortComparers
    System.Func<System.String, System.Linq.Expressions.Expression> GetExpressionFunc
    System.String[] properties
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>

    GroupByMany(IEnumerable, Type, List<SortDescription>, Func<String, Expression>, String[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany(this IEnumerable source, Type sourceType, List<SortDescription> sortFields, Func<string, Expression> GetExpressionFunc, params string[] properties)
    Parameters
    Type Name Description
    System.Collections.IEnumerable source
    System.Type sourceType
    System.Collections.Generic.List<SortDescription> sortFields
    System.Func<System.String, System.Linq.Expressions.Expression> GetExpressionFunc
    System.String[] properties
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>

    GroupByMany(IEnumerable, Type, Func<String, Expression>, String[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany(this IEnumerable source, Type sourceType, Func<string, Expression> GetExpressionFunc, params string[] properties)
    Parameters
    Type Name Description
    System.Collections.IEnumerable source
    System.Type sourceType
    System.Func<System.String, System.Linq.Expressions.Expression> GetExpressionFunc
    System.String[] properties
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>

    GroupByMany(IQueryable, Dictionary<String, String>, String[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, Dictionary<string, string> formatcoll, params string[] properties)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.Dictionary<System.String, System.String> formatcoll
    System.String[] properties
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>

    GroupByMany(IQueryable, Dictionary<String, String>, Type, String[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, Dictionary<string, string> formatColl, Type sourceType, params string[] properties)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.Dictionary<System.String, System.String> formatColl
    System.Type sourceType
    System.String[] properties
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>

    GroupByMany(IQueryable, IEnumerable<String>)

    Declaration
    public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, IEnumerable<string> properties)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IEnumerable<System.String> properties
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>

    GroupByMany(IQueryable, String[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, params string[] properties)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String[] properties
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>

    GroupByMany(IQueryable, Type, List<SortDescription>, String[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, Type sourceType, List<SortDescription> sortFields, params string[] properties)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Type sourceType
    System.Collections.Generic.List<SortDescription> sortFields
    System.String[] properties
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>

    GroupByMany(IQueryable, Type, String[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, Type sourceType, params string[] properties)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Type sourceType
    System.String[] properties
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>

    GroupByMany<TElement>(IEnumerable<TElement>, IEnumerable<Func<TElement, Object>>)

    Declaration
    public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, IEnumerable<Func<TElement, object>> groupSelectors)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<TElement> elements
    System.Collections.Generic.IEnumerable<System.Func<TElement, System.Object>> groupSelectors
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>
    Type Parameters
    Name Description
    TElement

    GroupByMany<TElement>(IEnumerable<TElement>, List<SortDescription>, Dictionary<String, IComparer<Object>>, List<String>, Func<TElement, Object>[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, List<SortDescription> sortFields, Dictionary<string, IComparer<object>> sortComparers, List<string> properties, params Func<TElement, object>[] groupSelectors)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<TElement> elements
    System.Collections.Generic.List<SortDescription> sortFields
    System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.IComparer<System.Object>> sortComparers
    System.Collections.Generic.List<System.String> properties
    System.Func<TElement, System.Object>[] groupSelectors
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>
    Type Parameters
    Name Description
    TElement

    GroupByMany<TElement>(IEnumerable<TElement>, List<SortDescription>, Dictionary<String, IComparer<Object>>, String[], IEnumerable<Func<TElement, Object>>)

    Declaration
    public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, List<SortDescription> sortFields, Dictionary<string, IComparer<object>> sortComparers, string[] properties, IEnumerable<Func<TElement, object>> groupSelectors)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<TElement> elements
    System.Collections.Generic.List<SortDescription> sortFields
    System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.IComparer<System.Object>> sortComparers
    System.String[] properties
    System.Collections.Generic.IEnumerable<System.Func<TElement, System.Object>> groupSelectors
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>
    Type Parameters
    Name Description
    TElement

    GroupByMany<TElement>(IEnumerable<TElement>, List<SortDescription>, IEnumerable<Func<TElement, Object>>)

    Declaration
    public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, List<SortDescription> sortFields, IEnumerable<Func<TElement, object>> groupSelectors)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<TElement> elements
    System.Collections.Generic.List<SortDescription> sortFields
    System.Collections.Generic.IEnumerable<System.Func<TElement, System.Object>> groupSelectors
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>
    Type Parameters
    Name Description
    TElement

    GroupByMany<TElement>(IEnumerable<TElement>, List<SortDescription>, Func<TElement, Object>[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, List<SortDescription> sortFields, params Func<TElement, object>[] groupSelectors)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<TElement> elements
    System.Collections.Generic.List<SortDescription> sortFields
    System.Func<TElement, System.Object>[] groupSelectors
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>
    Type Parameters
    Name Description
    TElement

    GroupByMany<TElement>(IEnumerable<TElement>, Func<TElement, Object>[])

    Declaration
    public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, params Func<TElement, object>[] groupSelectors)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<TElement> elements
    System.Func<TElement, System.Object>[] groupSelectors
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<GroupResult>
    Type Parameters
    Name Description
    TElement

    LessThan(ParameterExpression, String, Object)

    Declaration
    public static BinaryExpression LessThan(this ParameterExpression paramExpression, string propertyName, object value)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    LessThan(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)

    Declaration
    public static Expression LessThan(this ParameterExpression paramExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    System.Type elementType
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.Expressions.Expression

    LessThan(ParameterExpression, String, String)

    Declaration
    public static BinaryExpression LessThan(this ParameterExpression paramExpression, string propertyName, string propertyName2)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.String propertyName2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    LessThanOrEqual(ParameterExpression, String, Object)

    Declaration
    public static BinaryExpression LessThanOrEqual(this ParameterExpression paramExpression, string propertyName, object value)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    LessThanOrEqual(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)

    Declaration
    public static Expression LessThanOrEqual(this ParameterExpression paramExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    System.Type elementType
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.Expressions.Expression

    LessThanOrEqual(ParameterExpression, String, String)

    Declaration
    public static BinaryExpression LessThanOrEqual(this ParameterExpression paramExpression, string propertyName, string propertyName2)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.String propertyName2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    Max(IQueryable, String)

    Declaration
    public static object Max(this IQueryable source, string propertyName)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    Returns
    Type Description
    System.Object

    Max(IQueryable, String, Expression<Func<String, Object, Object>>)

    Declaration
    public static object Max(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Object

    Max(IQueryable, String, Type)

    Declaration
    public static object Max(this IQueryable source, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Type sourceType
    Returns
    Type Description
    System.Object

    Min(IQueryable, String)

    Declaration
    public static object Min(this IQueryable source, string propertyName)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    Returns
    Type Description
    System.Object

    Min(IQueryable, String, Expression<Func<String, Object, Object>>)

    Declaration
    public static object Min(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Object

    Min(IQueryable, String, Type)

    Declaration
    public static object Min(this IQueryable source, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Type sourceType
    Returns
    Type Description
    System.Object

    NotEqual(ParameterExpression, String, Object)

    Declaration
    public static BinaryExpression NotEqual(this ParameterExpression paramExpression, string propertyName, object value)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    NotEqual(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)

    Declaration
    public static Expression NotEqual(this ParameterExpression paramExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object value
    System.Type elementType
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.Expressions.Expression

    NotEqual(ParameterExpression, String, String)

    Declaration
    public static BinaryExpression NotEqual(this ParameterExpression paramExpression, string propertyName, string propertyName2)
    Parameters
    Type Name Description
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.String propertyName2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    OfQueryable(IEnumerable)

    Declaration
    public static IEnumerable OfQueryable(this IEnumerable items)
    Parameters
    Type Name Description
    System.Collections.IEnumerable items
    Returns
    Type Description
    System.Collections.IEnumerable

    OfQueryable(IEnumerable, Type)

    Declaration
    public static IEnumerable OfQueryable(this IEnumerable items, Type sourceType)
    Parameters
    Type Name Description
    System.Collections.IEnumerable items
    System.Type sourceType
    Returns
    Type Description
    System.Collections.IEnumerable

    OfType(IQueryable, Type)

    Declaration
    public static IQueryable OfType(this IQueryable source, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    OrderBy(IQueryable, ParameterExpression, Expression)

    Declaration
    public static IQueryable OrderBy(this IQueryable source, ParameterExpression paramExpression, Expression mExp)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Linq.Expressions.ParameterExpression paramExpression
    System.Linq.Expressions.Expression mExp
    Returns
    Type Description
    System.Linq.IQueryable

    OrderBy(IQueryable, String)

    Declaration
    public static IQueryable OrderBy(this IQueryable source, string propertyName)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    Returns
    Type Description
    System.Linq.IQueryable

    OrderBy(IQueryable, String, IComparer<Object>, Expression<Func<String, Object, Object>>)

    Declaration
    public static IQueryable OrderBy(this IQueryable source, string propertyName, IComparer<object> comparer, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Collections.Generic.IComparer<System.Object> comparer
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.IQueryable

    OrderBy(IQueryable, String, IComparer<Object>, Type)

    Declaration
    public static IQueryable OrderBy(this IQueryable source, string propertyName, IComparer<object> comparer, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Collections.Generic.IComparer<System.Object> comparer
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    OrderBy(IQueryable, String, Expression<Func<String, Object, Object>>)

    Declaration
    public static IQueryable OrderBy(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.IQueryable

    OrderBy(IQueryable, String, Type)

    Generates a OrderBy query for the Queryable source.

                DataClasses1DataContext db = new
    DataClasses1DataContext();
                var orders = db.Orders.Skip(0).Take(10).ToList();
                var queryable = orders.AsQueryable();
                var sortedOrders =
    queryable.OrderBy("ShipCountry");

    Declaration
    public static IQueryable OrderBy(this IQueryable source, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    OrderBy<T>(IQueryable, IComparer<T>)

    Declaration
    public static IQueryable OrderBy<T>(this IQueryable source, IComparer<T> comparer)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IComparer<T> comparer
    Returns
    Type Description
    System.Linq.IQueryable
    Type Parameters
    Name Description
    T

    OrderBy<T>(IQueryable, IComparer<T>, Type)

    Generates an OrderBy query for the IComparer defined.

       public class OrdersComparer :
    IComparer<Order>
        {
            public int Compare(Order x, Order y)
            {
                return string.Compare(x.ShipCountry, y.ShipCountry);
            }
        }

    var sortedOrders =
    db.Orders.Skip(0).Take(5).ToList().OrderBy(o => o, new
    OrdersComparer());

    Declaration
    public static IQueryable OrderBy<T>(this IQueryable source, IComparer<T> comparer, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IComparer<T> comparer
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable
    Type Parameters
    Name Description
    T

    OrderByDescending(IQueryable, ParameterExpression, Expression)

    Declaration
    public static IQueryable OrderByDescending(this IQueryable source, ParameterExpression paramExpression, Expression mExp)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Linq.Expressions.ParameterExpression paramExpression
    System.Linq.Expressions.Expression mExp
    Returns
    Type Description
    System.Linq.IQueryable

    OrderByDescending(IQueryable, String)

    Declaration
    public static IQueryable OrderByDescending(this IQueryable source, string propertyName)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    Returns
    Type Description
    System.Linq.IQueryable

    OrderByDescending(IQueryable, String, IComparer<Object>, Expression<Func<String, Object, Object>>)

    Declaration
    public static IQueryable OrderByDescending(this IQueryable source, string propertyName, IComparer<object> comparer, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Collections.Generic.IComparer<System.Object> comparer
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.IQueryable

    OrderByDescending(IQueryable, String, IComparer<Object>, Type)

    Declaration
    public static IQueryable OrderByDescending(this IQueryable source, string propertyName, IComparer<object> comparer, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Collections.Generic.IComparer<System.Object> comparer
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    OrderByDescending(IQueryable, String, Expression<Func<String, Object, Object>>)

    Declaration
    public static IQueryable OrderByDescending(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.IQueryable

    OrderByDescending(IQueryable, String, Type)

    Generates a OrderByDescending query for the Queryable source.

                DataClasses1DataContext db = new
    DataClasses1DataContext();
                var orders = db.Orders.Skip(0).Take(10).ToList();
                var queryable = orders.AsQueryable();
                var sortedOrders =
    queryable.OrderByDescending("ShipCountry");

    Declaration
    public static IQueryable OrderByDescending(this IQueryable source, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    OrderByDescending<T>(IQueryable, IComparer<T>)

    Declaration
    public static IQueryable OrderByDescending<T>(this IQueryable source, IComparer<T> comparer)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IComparer<T> comparer
    Returns
    Type Description
    System.Linq.IQueryable
    Type Parameters
    Name Description
    T

    OrderByDescending<T>(IQueryable, IComparer<T>, Type)

    Generates an OrderByDescending query for the IComparer defined.

       public class OrdersComparer :
    IComparer<Order>
        {
            public int Compare(Order x, Order y)
            {
                return string.Compare(x.ShipCountry, y.ShipCountry);
            }
        }

    var sortedOrders =
    db.Orders.Skip(0).Take(5).ToList().OrderByDescending(o => o, new
    OrdersComparer());

    Declaration
    public static IQueryable OrderByDescending<T>(this IQueryable source, IComparer<T> comparer, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IComparer<T> comparer
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable
    Type Parameters
    Name Description
    T

    OrElsePredicate(Expression, Expression)

    Declaration
    public static BinaryExpression OrElsePredicate(this Expression expr1, Expression expr2)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression expr1
    System.Linq.Expressions.Expression expr2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    OrPredicate(Expression, Expression)

    Generates an OR binary expression for the given Binary expressions.

    Declaration
    public static BinaryExpression OrPredicate(this Expression expr1, Expression expr2)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression expr1
    System.Linq.Expressions.Expression expr2
    Returns
    Type Description
    System.Linq.Expressions.BinaryExpression

    Page(IQueryable, Int32, Int32)

    Declaration
    public static IQueryable Page(this IQueryable source, int pageIndex, int pageSize)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Int32 pageIndex
    System.Int32 pageSize
    Returns
    Type Description
    System.Linq.IQueryable

    Parameter(IQueryable)

    Creates a ParameterExpression that is required when building a series of predicates for the WHERE filter.

            DataClasses1DataContext db = new
    DataClasses1DataContext();
            var orders = db.Orders.Skip(0).Take(100).ToList();
            var queryable = orders.AsQueryable();
            var parameter =
    queryable.Parameter();

    Use this same parameter passed to generate different predicates and finally to generate the Lambda.

    Declaration
    public static ParameterExpression Parameter(this IQueryable source)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    Returns
    Type Description
    System.Linq.Expressions.ParameterExpression
    Remarks

    If we specify a parameter for every predicate, then the Lambda expression scope will be out of the WHERE query that gets generated.

    Parameter(Type)

    Declaration
    public static ParameterExpression Parameter(this Type sourceType)
    Parameters
    Type Name Description
    System.Type sourceType
    Returns
    Type Description
    System.Linq.Expressions.ParameterExpression

    Predicate(IQueryable, ParameterExpression, String, Object, FilterType, FilterBehavior, Boolean, Type)

    Predicate is a Binary expression that needs to be built for a single or a series of values that needs to be passed on to the WHERE expression.

    var binaryExp = queryable.Predicate(parameter,
    "EmployeeID", "4", true);
    Declaration
    public static Expression Predicate(this IQueryable source, ParameterExpression paramExpression, string propertyName, object constValue, FilterType filterType, FilterBehavior filterBehaviour, bool isCaseSensitive, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object constValue
    FilterType filterType
    FilterBehavior filterBehaviour
    System.Boolean isCaseSensitive
    System.Type sourceType
    Returns
    Type Description
    System.Linq.Expressions.Expression
    Remarks

    First create a ParameterExpression using the Parameter extension function, then use the same ParameterExpression to generate the predicates.

    Predicate(IQueryable, ParameterExpression, String, Object, FilterType, FilterBehavior, Boolean, Type, Delegate, Type)

    Declaration
    public static Expression Predicate(this IQueryable source, ParameterExpression paramExpression, string propertyName, object constValue, FilterType filterType, FilterBehavior filterBehaviour, bool isCaseSensitive, Type sourceType, Delegate expressionFunc, Type memberType = null)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object constValue
    FilterType filterType
    FilterBehavior filterBehaviour
    System.Boolean isCaseSensitive
    System.Type sourceType
    System.Delegate expressionFunc
    System.Type memberType
    Returns
    Type Description
    System.Linq.Expressions.Expression

    Predicate(IQueryable, ParameterExpression, String, Object, FilterType, FilterBehavior, Boolean, Type, String)

    Declaration
    public static Expression Predicate(this IQueryable source, ParameterExpression paramExpression, string propertyName, object constValue, FilterType filterType, FilterBehavior filteBehaviour, bool isCaseSensitive, Type sourceType, string format)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object constValue
    FilterType filterType
    FilterBehavior filteBehaviour
    System.Boolean isCaseSensitive
    System.Type sourceType
    System.String format
    Returns
    Type Description
    System.Linq.Expressions.Expression

    Predicate(IQueryable, ParameterExpression, String, Object, Type, FilterType, FilterBehavior, Boolean, Type, Delegate)

    Declaration
    public static Expression Predicate(this IQueryable source, ParameterExpression paramExpression, string propertyName, object constValue, Type memberType, FilterType filterType, FilterBehavior filterBehaviour, bool isCaseSensitive, Type sourceType, Delegate expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Linq.Expressions.ParameterExpression paramExpression
    System.String propertyName
    System.Object constValue
    System.Type memberType
    FilterType filterType
    FilterBehavior filterBehaviour
    System.Boolean isCaseSensitive
    System.Type sourceType
    System.Delegate expressionFunc
    Returns
    Type Description
    System.Linq.Expressions.Expression

    Select(IQueryable, IEnumerable<String>)

    Declaration
    public static IQueryable Select(this IQueryable source, IEnumerable<string> properties)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IEnumerable<System.String> properties
    Returns
    Type Description
    System.Linq.IQueryable

    Select(IQueryable, IEnumerable<String>, Type)

    Generates a Select query based on the properties passed.

                DataClasses1DataContext db = new
    DataClasses1DataContext();
                var orders = db.Orders.Skip(0).Take(10).ToList();
                var queryable = orders.AsQueryable();
                var selector = queryable.Select(new List<string>() {
    "OrderID", "ShipCountry" });

    It returns a dynamic class generated thru ReflectionEmit, Use reflection to identify the properties and values.

    Declaration
    public static IQueryable Select(this IQueryable source, IEnumerable<string> properties, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IEnumerable<System.String> properties
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    Select(IQueryable, String)

    Declaration
    public static IQueryable Select(this IQueryable source, string propertyName)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    Returns
    Type Description
    System.Linq.IQueryable

    Select(IQueryable, String, Type)

    Generates a Select query for a single property value.

    Declaration
    public static IQueryable Select(this IQueryable source, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Type sourceType

    Type

    Returns
    Type Description
    System.Linq.IQueryable

    Select(IQueryable, String[])

    Generates a Select query based on the properties passed.

                DataClasses1DataContext db = new
    DataClasses1DataContext();
                var orders = db.Orders.Skip(0).Take(10).ToList();
                var queryable = orders.AsQueryable();
                var selector = queryable.Select(new string[]{
    "OrderID", "ShipCountry" });
    Declaration
    public static IQueryable Select(this IQueryable source, params string[] properties)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String[] properties
    Returns
    Type Description
    System.Linq.IQueryable

    Skip(IQueryable, Int32)

    Declaration
    public static IQueryable Skip(this IQueryable source, int constValue)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Int32 constValue
    Returns
    Type Description
    System.Linq.IQueryable

    Skip(IQueryable, Int32, Type)

    Generates a SKIP expression in the IQueryable source.

    Declaration
    public static IQueryable Skip(this IQueryable source, int constValue, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source

    The source.

    System.Int32 constValue

    The const value.

    System.Type sourceType

    Type

    Returns
    Type Description
    System.Linq.IQueryable

    Sum(IQueryable, String)

    Declaration
    public static object Sum(this IQueryable source, string propertyName)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    Returns
    Type Description
    System.Object

    Sum(IQueryable, String, Expression<Func<String, Object, Object>>, Expression<Func<String, Object, Object>>)

    Declaration
    public static object Sum(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc, Expression<Func<string, object, object>> typeFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> typeFunc
    Returns
    Type Description
    System.Object

    Sum(IQueryable, String, Type)

    Declaration
    public static object Sum(this IQueryable source, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Type sourceType
    Returns
    Type Description
    System.Object

    Take(IQueryable, Int32)

    Declaration
    public static IQueryable Take(this IQueryable source, int constValue)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Int32 constValue
    Returns
    Type Description
    System.Linq.IQueryable

    Take(IQueryable, Int32, Type)

    Generates a TAKE expression in the IQueryable source.

    Declaration
    public static IQueryable Take(this IQueryable source, int constValue, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source

    The source.

    System.Int32 constValue

    The const value.

    System.Type sourceType

    Type

    Returns
    Type Description
    System.Linq.IQueryable

    ThenBy(IQueryable, ParameterExpression, Expression)

    Declaration
    public static IQueryable ThenBy(this IQueryable source, ParameterExpression paramExpression, Expression mExp)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Linq.Expressions.ParameterExpression paramExpression
    System.Linq.Expressions.Expression mExp
    Returns
    Type Description
    System.Linq.IQueryable

    ThenBy(IQueryable, String)

    Declaration
    public static IQueryable ThenBy(this IQueryable source, string propertyName)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    Returns
    Type Description
    System.Linq.IQueryable

    ThenBy(IQueryable, String, IComparer<Object>, Expression<Func<String, Object, Object>>)

    Declaration
    public static IQueryable ThenBy(this IQueryable source, string propertyName, IComparer<object> comparer, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Collections.Generic.IComparer<System.Object> comparer
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.IQueryable

    ThenBy(IQueryable, String, IComparer<Object>, Type)

    Declaration
    public static IQueryable ThenBy(this IQueryable source, string propertyName, IComparer<object> comparer, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Collections.Generic.IComparer<System.Object> comparer
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    ThenBy(IQueryable, String, Expression<Func<String, Object, Object>>)

    Declaration
    public static IQueryable ThenBy(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.IQueryable

    ThenBy(IQueryable, String, Type)

    Generates a ThenBy query for the Queryable source.

                DataClasses1DataContext db = new
    DataClasses1DataContext();
                var orders = db.Orders.Skip(0).Take(10).ToList();
                var queryable = orders.AsQueryable();
                var sortedOrders = queryable.OrderBy("ShipCountry");
                sortedOrders = sortedOrders.ThenBy("ShipCity");
    Declaration
    public static IQueryable ThenBy(this IQueryable source, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    ThenBy<T>(IQueryable, IComparer<T>)

    Declaration
    public static IQueryable ThenBy<T>(this IQueryable source, IComparer<T> comparer)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IComparer<T> comparer
    Returns
    Type Description
    System.Linq.IQueryable
    Type Parameters
    Name Description
    T

    ThenBy<T>(IQueryable, IComparer<T>, Type)

    Generates an ThenBy query for the IComparer defined.

       public class OrdersComparer :
    IComparer<Order>
        {
            public int Compare(Order x, Order y)
            {
                return string.Compare(x.ShipCountry, y.ShipCountry);
            }
        }

    var sortedOrders =
    db.Orders.Skip(0).Take(5).ToList().ThenBy(o => o, new
    OrdersComparer());

    Declaration
    public static IQueryable ThenBy<T>(this IQueryable source, IComparer<T> comparer, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IComparer<T> comparer
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable
    Type Parameters
    Name Description
    T

    ThenByDescending(IQueryable, ParameterExpression, Expression)

    Declaration
    public static IQueryable ThenByDescending(this IQueryable source, ParameterExpression paramExpression, Expression mExp)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Linq.Expressions.ParameterExpression paramExpression
    System.Linq.Expressions.Expression mExp
    Returns
    Type Description
    System.Linq.IQueryable

    ThenByDescending(IQueryable, String)

    Declaration
    public static IQueryable ThenByDescending(this IQueryable source, string propertyName)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    Returns
    Type Description
    System.Linq.IQueryable

    ThenByDescending(IQueryable, String, IComparer<Object>, Expression<Func<String, Object, Object>>)

    Declaration
    public static IQueryable ThenByDescending(this IQueryable source, string propertyName, IComparer<object> comparer, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Collections.Generic.IComparer<System.Object> comparer
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.IQueryable

    ThenByDescending(IQueryable, String, IComparer<Object>, Type)

    Declaration
    public static IQueryable ThenByDescending(this IQueryable source, string propertyName, IComparer<object> comparer, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Collections.Generic.IComparer<System.Object> comparer
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    ThenByDescending(IQueryable, String, Expression<Func<String, Object, Object>>)

    Declaration
    public static IQueryable ThenByDescending(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> expressionFunc
    Returns
    Type Description
    System.Linq.IQueryable

    ThenByDescending(IQueryable, String, Type)

    Generates a ThenByDescending query for the Queryable source.

                DataClasses1DataContext db = new
    DataClasses1DataContext();
                var orders = db.Orders.Skip(0).Take(10).ToList();
                var queryable = orders.AsQueryable();
                var sortedOrders = queryable.OrderBy("ShipCountry");
                sortedOrders = sortedOrders.ThenByDescending("ShipCity");
    Declaration
    public static IQueryable ThenByDescending(this IQueryable source, string propertyName, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable

    ThenByDescending<T>(IQueryable, IComparer<T>)

    Declaration
    public static IQueryable ThenByDescending<T>(this IQueryable source, IComparer<T> comparer)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IComparer<T> comparer
    Returns
    Type Description
    System.Linq.IQueryable
    Type Parameters
    Name Description
    T

    ThenByDescending<T>(IQueryable, IComparer<T>, Type)

    Generates an ThenByDescending query for the IComparer defined.

       public class OrdersComparer :
    IComparer<Order>
        {
            public int Compare(Order x, Order y)
            {
                return string.Compare(x.ShipCountry, y.ShipCountry);
            }
        }

    var sortedOrders =
    db.Orders.Skip(0).Take(5).ToList().ThenByDescending(o => o, new
    OrdersComparer());

    Declaration
    public static IQueryable ThenByDescending<T>(this IQueryable source, IComparer<T> comparer, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Collections.Generic.IComparer<T> comparer
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable
    Type Parameters
    Name Description
    T

    Where(IQueryable, ParameterExpression, Expression)

    Use this function to generate WHERE expression based on Predicates. The AndPredicate and OrPredicate should be used in combination to build the predicate expression which is finally passed on to this function for creating a Lambda.

    DataClasses1DataContext db = new DataClasses1DataContext();

    var orders = db.Orders.Skip(0).Take(100).ToList();

    var queryable = orders.AsQueryable();

    var parameter = queryable.Parameter("ShipCountry");

    var binaryExp = queryable.Predicate(parameter,

    "ShipCountry", "USA", true);

    var filteredOrders = queryable.Where(parameter, binaryExp);

    foreach (var order in filteredOrders)

    {

    Console.WriteLine(order);

    }

    Build Predicates for Contains / StartsWith / EndsWith,

    IQueryable queryable = nw.Orders.AsQueryable();

    var parameter = queryable.Parameter();

    var exp1 = queryable.Predicate(parameter, "ShipCountry", "h", FilterType.Contains);

    var exp2 = queryable.Predicate(parameter, "ShipCountry", "a", FilterType.StartsWith);

    var andExp = exp2.OrPredicate(exp1);

    var filters = queryable.Where(parameter, andExp);

    foreach (Orders item in filters)

    {

    Console.WriteLine("{0}/{1}", item.OrderID, item.ShipCountry);

    }

    Declaration
    public static IQueryable Where(this IQueryable source, ParameterExpression paramExpression, Expression predicateExpression)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.Linq.Expressions.ParameterExpression paramExpression
    System.Linq.Expressions.Expression predicateExpression
    Returns
    Type Description
    System.Linq.IQueryable

    Where(IQueryable, String, Object, FilterType, Boolean)

    Declaration
    public static IQueryable Where(this IQueryable source, string propertyName, object value, FilterType filterType, bool isCaseSensitive)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName
    System.Object value
    FilterType filterType
    System.Boolean isCaseSensitive
    Returns
    Type Description
    System.Linq.IQueryable

    Where(IQueryable, String, Object, FilterType, Boolean, Type)

    Generates the where expression.

                var nw = new Northwind(@"Data Source =
    Northwind.sdf");
                IQueryable queryable = nw.Orders.AsQueryable();
                var filters = queryable.Where("ShipCountry",
    "z", FilterType.Contains);
                foreach (Orders item in filters)
                {
                    Console.WriteLine("{0}/{1}", item.OrderID,
    item.ShipCountry);
                }
    Declaration
    public static IQueryable Where(this IQueryable source, string propertyName, object value, FilterType filterType, bool isCaseSensitive, Type sourceType)
    Parameters
    Type Name Description
    System.Linq.IQueryable source
    System.String propertyName

    Name of the property.

    System.Object value
    FilterType filterType
    System.Boolean isCaseSensitive
    System.Type sourceType
    Returns
    Type Description
    System.Linq.IQueryable
    Back to top Generated by DocFX
    Copyright © 2001 - 2021 Syncfusion Inc. All Rights Reserved