Class QueryableExtensions
Inheritance
Namespace: Syncfusion.DataSource.Extensions
Assembly: Syncfusion.DataSource.Portable.dll
Syntax
public static class QueryableExtensions : Object
Methods
AndAlsoPredicate(Expression, Expression)
Generates an ANDAlso binary expression for the given expressions.
Declaration
public static BinaryExpression AndAlsoPredicate(this Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression1 | The expression 1. |
System.Linq.Expressions.Expression | expression2 | The expression 2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | An ANDAlso binary expression for the given expressions. |
AndPredicate(Expression, Expression)
Generates an AND binary expression for the given Binary expressions.
Declaration
public static BinaryExpression AndPredicate(this Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression1 | Represents the expression1. |
System.Linq.Expressions.Expression | expression2 | Represents the expression2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | Returns the binary expression. |
Average(IQueryable, String)
Calculates the average by executing the expression obtained from the queryable average method based on the given source and the property name.
Declaration
public static object Average(this IQueryable source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
Returns
Type | Description |
---|---|
System.Object | The average by executing the expression obtained from the queryable average method based on the given source and the property name. |
Average(IQueryable, String, Expression<Func<String, Object, Object>>)
Calculates the average by executing the expression obtained from the queryable average method based on the given source, property name and the expression function.
Declaration
public static object Average(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function. |
Returns
Type | Description |
---|---|
System.Object | The average by executing the expression obtained from the queryable average method based on the given source, property name and the expression function. |
Average(IQueryable, String, Type)
Calculates the average by executing the expression obtained from the queryable average method based on the given source and the property name.
Declaration
public static object Average(this IQueryable source, string propertyName, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Type | sourceType | The source type. |
Returns
Type | Description |
---|---|
System.Object | The average by executing the expression obtained from the queryable average method based on the given source and the property name. |
Count(IQueryable)
Gets the execution times count of the given queryable source.
Declaration
public static int Count(this IQueryable source)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The source which is to be queried. |
Returns
Type | Description |
---|---|
System.Int32 | The count of the execution times of the given queryable source. |
ElementAt(IQueryable, Int32)
Gets the element at the given index and the source.
Declaration
public static object ElementAt(this IQueryable source, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Int32 | index | The index at which the element is to be obtained. |
Returns
Type | Description |
---|---|
System.Object | The element at the given index and the source. |
ElementAt(IQueryable, Int32, Type)
Gets the element at the given index and the source.
Declaration
public static object ElementAt(this IQueryable source, int index, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Int32 | index | The index at which the element is to be obtained. |
System.Type | sourceType | The type of the source. |
Returns
Type | Description |
---|---|
System.Object | The element at the given index and the source. |
ElementAtOrDefault(IQueryable, Int32)
Gets the element at or default of the given index and the source.
Declaration
public static object ElementAtOrDefault(this IQueryable source, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Int32 | index | The index at which the element is to be obtained. |
Returns
Type | Description |
---|---|
System.Object | The element at the given index and the source. |
ElementAtOrDefault(IQueryable, Int32, Type)
Gets the element at or default of the given index and the source.
Declaration
public static object ElementAtOrDefault(this IQueryable source, int index, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Int32 | index | The index at which the element is to be obtained. |
System.Type | sourceType | The type of the source. |
Returns
Type | Description |
---|---|
System.Object | The element at or default of the given index and the type of source. |
Equal(ParameterExpression, String, Object)
Generates the equal expression for the given parameter expression, property and value.
Declaration
public static Expression Equal(this ParameterExpression parameterExpression, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression based on which the expression is generated. |
System.String | propertyName | The property name for which the expression is to be generated. |
System.Object | value | The object. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | The equal expression for the given parameter expression, property and value. |
Equal(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)
Generates an equal expression for the given values.
Declaration
public static Expression Equal(this ParameterExpression parameterExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunction)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name for which the expression is generated. |
System.Object | value | The object. |
System.Type | elementType | The type of the element. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunction | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | An equal expression for the given values. |
Equal(ParameterExpression, String, String)
Generates an equal binary expression for the given expression and the property name.
Declaration
public static BinaryExpression Equal(this ParameterExpression parameterExpression, string propertyName, string propertyName2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression for generating the binary expression. |
System.String | propertyName | The property name 1. |
System.String | propertyName2 | The property name 2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | An equal binary expression for the given expression and the property name. |
GetExpression(ParameterExpression, String)
Gets the expression for the given property and the parameter expression.
Declaration
public static Expression GetExpression(this ParameterExpression parameterExpression, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression based on which the expression is generated. |
System.String | propertyName | The property name for which the expression is to be generated. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | The expression for the given property and the parameter expression. |
GetObjectType(IQueryable)
Gets the type of the given source.
Declaration
public static Type GetObjectType(this IQueryable source)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The source, whose type is to be obtained. |
Returns
Type | Description |
---|---|
System.Type | The type of the given object. |
GetValueExpression(ParameterExpression, String, Type)
Generate expression from simple and complex property
Declaration
public static Expression GetValueExpression(this ParameterExpression parameterExpression, string propertyName, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | Represents the parameter expression. |
System.String | propertyName | Represents the property name. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Returns the expression. |
GreaterThan(ParameterExpression, String, Object)
Generates a GreaterThan binary expression for the given parameter expression, property and the value.
Declaration
public static BinaryExpression GreaterThan(this ParameterExpression parameterExpression, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | value | The object. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | A GreaterThan binary expression for the given parameter expression, property and the value. |
GreaterThan(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)
Generates a GreaterThan expression for the given values.
Declaration
public static Expression GreaterThan(this ParameterExpression parameterExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunction)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | value | The object. |
System.Type | elementType | The element type. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunction | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | A GreaterThan expression for the given values. |
GreaterThan(ParameterExpression, String, String)
Generates a GreaterThan binary expression for the given expression and the property.
Declaration
public static BinaryExpression GreaterThan(this ParameterExpression parameterExpression, string propertyName, string propertyName2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name 1. |
System.String | propertyName2 | The property name 2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | A GreaterThan binary expression for the given values. |
GreaterThanOrEqual(ParameterExpression, String, Object)
Generates a GreaterThanOrEqual binary expression for the given expression, property and the value.
Declaration
public static BinaryExpression GreaterThanOrEqual(this ParameterExpression parameterExpression, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | value | The object. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | A GreaterThanOrEqual binary expression for the given expression, property and the value. |
GreaterThanOrEqual(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)
Generates a GreaterThanOrEqual binary expression for the given values.
Declaration
public static Expression GreaterThanOrEqual(this ParameterExpression parameterExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunc)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | value | The object. |
System.Type | elementType | The element type. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | A GreaterThanOrEqual binary expression for the given values. |
GreaterThanOrEqual(ParameterExpression, String, String)
Generates a GreaterThanOrEqual binary expression for the given expressions and the property.
Declaration
public static BinaryExpression GreaterThanOrEqual(this ParameterExpression parameterExpression, string propertyName, string propertyName2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name 1. |
System.String | propertyName2 | The property name 2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | A GreaterThanOrEqual binary expression for the given expressions and the property. |
GroupBy(IQueryable, IEnumerable<SortColumn>)
Gets the GroupBy query expression for the given source and enumerable collection of the sort columns.
Declaration
public static IQueryable GroupBy(this IQueryable source, IEnumerable<SortColumn> groupByNames)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Collections.Generic.IEnumerable<SortColumn> | groupByNames | The enumerable collection of the sort columns group by names. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | The GroupBy query expression for the given source and enumerable collection of the sort columns. |
GroupBy(IQueryable, IEnumerable<SortColumn>, Type)
Gets the GroupBy query expression for the given source and enumerable collection of the sort columns.
Declaration
public static IQueryable GroupBy(this IQueryable source, IEnumerable<SortColumn> groupByNames, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Collections.Generic.IEnumerable<SortColumn> | groupByNames | The enumerable collection of the sort columns group by names. |
System.Type | sourceType | The type of the source. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | The GroupBy query expression for the given source and enumerable collection of the sort columns. |
GroupBy(IQueryable, String, String)
Gets the GroupBy query expression for the given source, group name and sort action.
Declaration
public static IQueryable GroupBy(this IQueryable source, string groupByName, string sortAction)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | groupByName | The group by name which is the property name. |
System.String | sortAction | The sort action. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | The GroupBy query expression for the given source, group name and sort action. |
GroupBy(IQueryable, String, String, Type)
Generates the GroupBy Expression
Declaration
public static IQueryable GroupBy(this IQueryable source, string groupByName, string sortAction, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the queryable source. |
System.String | groupByName | Represents the group name. |
System.String | sortAction | Represents the sort action. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns queryable objects. |
GroupByMany(IEnumerable, Type, List<SortDescriptor>, Dictionary<String, IComparer<Object>>, Func<String, Expression>, String[])
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany(this IEnumerable source, Type sourceType, List<SortDescriptor> sortFields, Dictionary<string, IComparer<object>> sortComparers, Func<string, Expression> getExpressionFunc, params string[] properties)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | source | The IEnumerable source. |
System.Type | sourceType | The type of the source. |
System.Collections.Generic.List<SortDescriptor> | sortFields | The list of sort descriptions. |
System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.IComparer<System.Object>> | sortComparers | The dictionary of sort comparers. |
System.Func<System.String, System.Linq.Expressions.Expression> | getExpressionFunc | The expression function. |
System.String[] | properties | The array of properties. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
GroupByMany(IEnumerable, Type, List<SortDescriptor>, Func<String, Expression>, String[])
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany(this IEnumerable source, Type sourceType, List<SortDescriptor> sortFields, Func<string, Expression> getExpressionFunc, params string[] properties)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | source | The IEnumerable source. |
System.Type | sourceType | The type of the source. |
System.Collections.Generic.List<SortDescriptor> | sortFields | The list of sort descriptions. |
System.Func<System.String, System.Linq.Expressions.Expression> | getExpressionFunc | The expression function. |
System.String[] | properties | The array of properties. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
GroupByMany(IEnumerable, Type, Func<String, Expression>, String[])
Generates the GroupResult enumerable collection based on the given values.
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 | The IQueryable source. |
System.Type | sourceType | The type of the source. |
System.Func<System.String, System.Linq.Expressions.Expression> | getExpressionFunc | The expression function. |
System.String[] | properties | The array of properties. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
GroupByMany(IQueryable, Dictionary<String, String>, String[])
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, Dictionary<string, string> formatCollection, params string[] properties)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Collections.Generic.Dictionary<System.String, System.String> | formatCollection | The dictionary of format collection. |
System.String[] | properties | The array of properties. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection for the given values. |
GroupByMany(IQueryable, Dictionary<String, String>, Type, String[])
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, Dictionary<string, string> formatCollection, Type sourceType, params string[] properties)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Collections.Generic.Dictionary<System.String, System.String> | formatCollection | The dictionary of format collection. |
System.Type | sourceType | The type of the source. |
System.String[] | properties | The array of properties. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
GroupByMany(IQueryable, IEnumerable<String>)
Generates the GroupResult enumerable collection based on the given source and the properties passed.
Declaration
public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, IEnumerable<string> properties)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source |
System.Collections.Generic.IEnumerable<System.String> | properties | The enumerable collection of properties. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given source and the properties passed. |
GroupByMany(IQueryable, String[])
Generates the GroupResult enumerable collection for the given source and the properties passed.
Declaration
public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, params string[] properties)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String[] | properties | The array of properties. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection for the given source and the properties passed. |
GroupByMany(IQueryable, Type, List<SortDescriptor>, String[])
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, Type sourceType, List<SortDescriptor> sortFields, params string[] properties)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Type | sourceType | The type of the source. |
System.Collections.Generic.List<SortDescriptor> | sortFields | The list of sort descriptions. |
System.String[] | properties | The array of properties. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
GroupByMany(IQueryable, Type, String[])
Generates the GroupResult enumerable collection based on the given source and the properties.
Declaration
public static IEnumerable<GroupResult> GroupByMany(this IQueryable source, Type sourceType, params string[] properties)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source |
System.Type | sourceType | The type of the source. |
System.String[] | properties | The array of properties. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given source and the properties. |
GroupByMany<TElement>(IEnumerable<TElement>, IEnumerable<Func<TElement, Object>>)
Generates the GroupResult enumerable collection based on the given values.
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 | The enumerable collection of the elements. |
System.Collections.Generic.IEnumerable<System.Func<TElement, System.Object>> | groupSelectors | The enumerable collection of function for the group selectors. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
Type Parameters
Name | Description |
---|---|
TElement | The type parameter. |
GroupByMany<TElement>(IEnumerable<TElement>, List<SortDescriptor>, Dictionary<String, IComparer<Object>>, List<String>, Func<TElement, Object>[])
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, List<SortDescriptor> sortFields, Dictionary<string, IComparer<object>> sortComparers, List<string> properties, params Func<TElement, object>[] groupSelectors)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TElement> | elements | The enumerable collection of the elements. |
System.Collections.Generic.List<SortDescriptor> | sortFields | The list of sort descriptions. |
System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.IComparer<System.Object>> | sortComparers | The sort comparers collection. |
System.Collections.Generic.List<System.String> | properties | The array of properties. |
System.Func<TElement, System.Object>[] | groupSelectors | The function for the group selectors. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
Type Parameters
Name | Description |
---|---|
TElement | The type parameter. |
GroupByMany<TElement>(IEnumerable<TElement>, List<SortDescriptor>, Dictionary<String, IComparer<Object>>, String[], IEnumerable<Func<TElement, Object>>)
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, List<SortDescriptor> sortFields, Dictionary<string, IComparer<object>> sortComparers, string[] properties, IEnumerable<Func<TElement, object>> groupSelectors)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TElement> | elements | The enumerable collection of the elements. |
System.Collections.Generic.List<SortDescriptor> | sortFields | The list of sort descriptions. |
System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.IComparer<System.Object>> | sortComparers | The sort comparers collection. |
System.String[] | properties | The array of properties. |
System.Collections.Generic.IEnumerable<System.Func<TElement, System.Object>> | groupSelectors | The enumerable collection of the function for the group selectors. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
Type Parameters
Name | Description |
---|---|
TElement | The type of the elements. |
GroupByMany<TElement>(IEnumerable<TElement>, List<SortDescriptor>, IEnumerable<Func<TElement, Object>>)
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, List<SortDescriptor> sortFields, IEnumerable<Func<TElement, object>> groupSelectors)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TElement> | elements | The enumerable collection of the elements. |
System.Collections.Generic.List<SortDescriptor> | sortFields | The list of sort descriptions. |
System.Collections.Generic.IEnumerable<System.Func<TElement, System.Object>> | groupSelectors | The enumerable collection of the function for the group selectors. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
Type Parameters
Name | Description |
---|---|
TElement | The type of the elements. |
GroupByMany<TElement>(IEnumerable<TElement>, List<SortDescriptor>, Func<TElement, Object>[])
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable<TElement> elements, List<SortDescriptor> sortFields, params Func<TElement, object>[] groupSelectors)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TElement> | elements | The enumerable collection of the elements. |
System.Collections.Generic.List<SortDescriptor> | sortFields | The list of sort descriptions. |
System.Func<TElement, System.Object>[] | groupSelectors | The function for the group selectors. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
Type Parameters
Name | Description |
---|---|
TElement | The type of the elements. |
GroupByMany<TElement>(IEnumerable<TElement>, Func<TElement, Object>[])
Generates the GroupResult enumerable collection based on the given values.
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 | The enumerable collection of the elements. |
System.Func<TElement, System.Object>[] | groupSelectors | The function for the group selectors. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | The GroupResult enumerable collection based on the given values. |
Type Parameters
Name | Description |
---|---|
TElement | The type of the elements. |
GroupByMany<TElement>(IEnumerable, Type, List<Func<TElement, Object>>)
Generates the GroupResult enumerable collection based on the given values.
Declaration
public static IEnumerable<GroupResult> GroupByMany<TElement>(this IEnumerable source, Type sourceType, List<Func<TElement, object>> groupKeySelectors)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | source | The enumerable collection of the elements. |
System.Type | sourceType | The type of the source. |
System.Collections.Generic.List<System.Func<TElement, System.Object>> | groupKeySelectors | The function for the group selectors. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<GroupResult> | Returns the enumerable collection. |
Type Parameters
Name | Description |
---|---|
TElement | The type parameter. |
LessThan(ParameterExpression, String, Object)
Generates a LessThan binary expression for the given expression, property and the values.
Declaration
public static BinaryExpression LessThan(this ParameterExpression parameterExpression, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | value | The object. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | A LessThan binary expression for the given expression, property and the values. |
LessThan(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)
Generates a LessThan expression for the given values.
Declaration
public static Expression LessThan(this ParameterExpression parameterExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunction)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | value | The object. |
System.Type | elementType | The element type. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunction | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | A LessThan expression for the given values. |
LessThan(ParameterExpression, String, String)
Generates a LessThan binary expression for the given expression and the property.
Declaration
public static BinaryExpression LessThan(this ParameterExpression parameterExpression, string propertyName, string propertyName2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name 1. |
System.String | propertyName2 | The property name 2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | A LessThan binary expression for the given expression and the property. |
LessThanOrEqual(ParameterExpression, String, Object)
Generates a LessThanOrEqual binary expression for the given expression, property and the value.
Declaration
public static BinaryExpression LessThanOrEqual(this ParameterExpression parameterExpression, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | value | The object. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | A LessThanOrEqual binary expression for the given expression, property and the value. |
LessThanOrEqual(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)
Generates a LessThanOrEqual expression for the given values.
Declaration
public static Expression LessThanOrEqual(this ParameterExpression parameterExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunction)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | value | The object. |
System.Type | elementType | The element type. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunction | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | A LessThanOrEqual expression for the given values. |
LessThanOrEqual(ParameterExpression, String, String)
Generates a LessThanOrEqual binary expression for the given expression and property.
Declaration
public static BinaryExpression LessThanOrEqual(this ParameterExpression parameterExpression, string propertyName, string propertyName2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name 1. |
System.String | propertyName2 | The property name 2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | A LessThanOrEqual binary expression for the given expression and property. |
Max(IQueryable, String)
Calculates the max object by executing the expression obtained from the queryable max method based on the given source and the property name.
Declaration
public static object Max(this IQueryable source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
Returns
Type | Description |
---|---|
System.Object | The max object by executing the expression obtained from the queryable max method based on the given source and the property name. |
Max(IQueryable, String, Expression<Func<String, Object, Object>>)
Calculates the max object by executing the expression obtained from the queryable max method based on the given values.
Declaration
public static object Max(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function. |
Returns
Type | Description |
---|---|
System.Object | The max object by executing the expression obtained from the queryable max method based on the given values. |
Max(IQueryable, String, Type)
Calculates the max object by executing the expression obtained from the queryable max method based on the given source and the property name.
Declaration
public static object Max(this IQueryable source, string propertyName, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Type | sourceType | The source type. |
Returns
Type | Description |
---|---|
System.Object | The max object by executing the expression obtained from the queryable max method based on the given source and the property name. |
Min(IQueryable, String)
Calculates the min object by executing the expression obtained from the queryable min method based on the given source and the property.
Declaration
public static object Min(this IQueryable source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
Returns
Type | Description |
---|---|
System.Object | The min object by executing the expression obtained from the queryable min method based on the given source and the property. |
Min(IQueryable, String, Expression<Func<String, Object, Object>>)
Calculates the min object by executing the expression obtained from the queryable min method based on the given values.
Declaration
public static object Min(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function. |
Returns
Type | Description |
---|---|
System.Object | The min object by executing the expression obtained from the queryable min method based on the given values. |
Min(IQueryable, String, Type)
Calculates the min object by executing the expression obtained from the queryable min method based on the given source and the property.
Declaration
public static object Min(this IQueryable source, string propertyName, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Type | sourceType | The source type. |
Returns
Type | Description |
---|---|
System.Object | The min object by executing the expression obtained from the queryable min method based on the given source and the property. |
NotEqual(ParameterExpression, String, Object)
Generates a NotEqual binary expression for the given parameter expression, property and the value.
Declaration
public static BinaryExpression NotEqual(this ParameterExpression parameterExpression, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name for which the expression is to be generated. |
System.Object | value | The object. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | A NotEqual binary expression for the given parameter expression, property and the value. |
NotEqual(ParameterExpression, String, Object, Type, Expression<Func<String, Object, Object>>)
Generates a NotEqual expression for the given values.
Declaration
public static Expression NotEqual(this ParameterExpression parameterExpression, string propertyName, object value, Type elementType, Expression<Func<string, object, object>> expressionFunction)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name for which the expression is generated. |
System.Object | value | The object. |
System.Type | elementType | The element type. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunction | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | A NotEqual expression for the given values. |
NotEqual(ParameterExpression, String, String)
Generates an NotEqual binary expression for the given expression and property.
Declaration
public static BinaryExpression NotEqual(this ParameterExpression parameterExpression, string propertyName, string propertyName2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name 1. |
System.String | propertyName2 | The property name 2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | An NotEqual binary expression for the given expression and property. |
OfQueryable(IEnumerable)
Determines the queryable which iterates over the given collection of items.
Declaration
public static IEnumerable OfQueryable(this IEnumerable items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | items | Represents the enumerable collection of items. |
Returns
Type | Description |
---|---|
System.Collections.IEnumerable | Returns the queryable which iterates over the given collection of items. |
OfQueryable(IEnumerable, Type)
Determines the queryable which iterates over the given collection of items
Declaration
public static IEnumerable OfQueryable(this IEnumerable items, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | items | Represents the enumerable collection of items. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Collections.IEnumerable | Returns the queryable which iterates over the given collection of items. |
OfType(IQueryable, Type)
Gets the queryable expression OfType for the given source and its type.
Declaration
public static IQueryable OfType(this IQueryable source, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Type | sourceType | The type of the source. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | The queryable expression OfType for the given source and its type. |
OfType<T, K>(ObservableCollection<K>)
Gets the collection of the type parameter T
for the given collection of
type parameter K
.
Declaration
public static ObservableCollection<T> OfType<T, K>(this ObservableCollection<K> items)
where K : T
Parameters
Type | Name | Description |
---|---|---|
System.Collections.ObjectModel.ObservableCollection<K> | items | The collection of items. |
Returns
Type | Description |
---|---|
System.Collections.ObjectModel.ObservableCollection<T> | The collection of the type parameter |
Type Parameters
Name | Description |
---|---|
T | The target type parameter. |
K | The given type parameter. |
OrderBy(IQueryable, ParameterExpression, Expression)
Generates a OrderBy query for the Queryable source.
Declaration
public static IQueryable OrderBy(this IQueryable source, ParameterExpression parameterExpression, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the queryable source. |
System.Linq.Expressions.ParameterExpression | parameterExpression | Represents the parameter expression. |
System.Linq.Expressions.Expression | expression | Represents the expression. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Represents the queryable objects. |
OrderBy(IQueryable, String)
Generates a OrderBy query for the Queryable source.
Declaration
public static IQueryable OrderBy(this IQueryable source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the queryable source. |
System.String | propertyName | Represents the property name. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable source. |
OrderBy(IQueryable, String, IComparer<Object>, Expression<Func<String, Object, Object>>)
Generates a OrderBy query for the Queryable source.
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 | Represents the queryable source. |
System.String | propertyName | Represents the property name. |
System.Collections.Generic.IComparer<System.Object> | comparer | Represents the comparer object. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | Represents the expression function. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
OrderBy(IQueryable, String, IComparer<Object>, Type)
Generates an OrderBy query for the IComparer defined and queryable source.
Declaration
public static IQueryable OrderBy(this IQueryable source, string propertyName, IComparer<object> comparer, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the queryable source. |
System.String | propertyName | Represents the property name. |
System.Collections.Generic.IComparer<System.Object> | comparer | Represents the comparer. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable source. |
OrderBy(IQueryable, String, Expression<Func<String, Object, Object>>)
Generates a OrderBy query for the Queryable source.
Declaration
public static IQueryable OrderBy(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the queryable source. |
System.String | propertyName | Represents the property name. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | Represents the function expression. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
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 | Represents the queryable source. |
System.String | propertyName | Represents the property name. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
OrderBy<T>(IQueryable, IComparer<T>)
Generates a OrderBy query for the Queryable source and Comparer.
Declaration
public static IQueryable OrderBy<T>(this IQueryable source, IComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the queryable source. |
System.Collections.Generic.IComparer<T> | comparer | Represents the comparer objects. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
Type Parameters
Name | Description |
---|---|
T | Represents the generic type parameter. |
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 | The queryable source |
System.Collections.Generic.IComparer<T> | comparer | The comparer |
System.Type | sourceType | The queryable source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
OrderByDescending(IQueryable, ParameterExpression, Expression)
Generates the OrderByDescending query for the given source and expressions.
Declaration
public static IQueryable OrderByDescending(this IQueryable source, ParameterExpression parameterExpression, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression which are the objects to populate to the parameter collection of the lambda expression. |
System.Linq.Expressions.Expression | expression | The expression to set the lambda expression body property equals to. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | The OrderByDescending query for the given source and expressions. |
OrderByDescending(IQueryable, String)
Generates the OrderByDescending query for the given source and the property.
Declaration
public static IQueryable OrderByDescending(this IQueryable source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name for which the query is to be generated. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | The OrderByDescending query for the given source and the property. |
OrderByDescending(IQueryable, String, IComparer<Object>, Expression<Func<String, Object, Object>>)
Generates the OrderByDescending query for the given source, property, expression function and the comparer defined.
Declaration
public static IQueryable OrderByDescending(this IQueryable source, string propertyName, IComparer<object> comparer, Expression<Func<string, object, object>> expressionFunction)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name for which the query is to be generated. |
System.Collections.Generic.IComparer<System.Object> | comparer | The comparer defined for the query. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunction | The expression function based on which the query is to be generated. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable object. |
OrderByDescending(IQueryable, String, IComparer<Object>, Type)
Generates an OrderByDescending query for the IComparer and queryable source defined.
Declaration
public static IQueryable OrderByDescending(this IQueryable source, string propertyName, IComparer<object> comparer, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the queryable source. |
System.String | propertyName | Represents the property name. |
System.Collections.Generic.IComparer<System.Object> | comparer | Represents the comparer objects. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
OrderByDescending(IQueryable, String, Expression<Func<String, Object, Object>>)
Generates the OrderByDescending query for the given source, property and the expression function.
Declaration
public static IQueryable OrderByDescending(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name for which the query is to be generated. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function based on which the query is to be generated. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | The OrderByDescending query for the given source, property and the expression function. |
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 | Represents the queryable source |
System.String | propertyName | Represents the property name. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
OrderByDescending<T>(IQueryable, IComparer<T>)
Generates an OrderByDescending query for the IComparer and queryable source defined.
Declaration
public static IQueryable OrderByDescending<T>(this IQueryable source, IComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the queryable source. |
System.Collections.Generic.IComparer<T> | comparer | Represents the comparer objects. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
Type Parameters
Name | Description |
---|---|
T | Represents the generic type parameter. |
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 | Represents the queryable source |
System.Collections.Generic.IComparer<T> | comparer | Represents the comparer. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
OrElsePredicate(Expression, Expression)
Generates an OrElse binary expression for the given expressions.
Declaration
public static BinaryExpression OrElsePredicate(this Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression1 | The expression 1. |
System.Linq.Expressions.Expression | expression2 | The expression 2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | An OrElse binary expression for the given expressions. |
OrPredicate(Expression, Expression)
Generates an OR binary expression for the given Binary expressions.
Declaration
public static BinaryExpression OrPredicate(this Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression1 | Represents the expression1. |
System.Linq.Expressions.Expression | expression2 | Represents the expression2. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.BinaryExpression | Returns the binary expression. |
Page(IQueryable, Int32, Int32)
Generates the page expression for the given source, page index and page size.
Declaration
public static IQueryable Page(this IQueryable source, int pageIndex, int pageSize)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Int32 | pageIndex | The index of the page. |
System.Int32 | pageSize | The size of the page. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | The page expression for the given source, page index and page size. |
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 | Represents the queryable source. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.ParameterExpression | Returns the parameter expression. |
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)
Generates the parameter expression for the given source type.
Declaration
public static ParameterExpression Parameter(this Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | sourceType | The source type. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.ParameterExpression | The parameter expression for the given source type. |
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 parameterExpression, string propertyName, object constantValue, FilterType filterType, FilterBehavior filterBehavior, bool isCaseSensitive, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the queryable source. |
System.Linq.Expressions.ParameterExpression | parameterExpression | Represents the parameter expression. |
System.String | propertyName | Represents the property name. |
System.Object | constantValue | Represents the constant value. |
FilterType | filterType | Represents the filter value. |
FilterBehavior | filterBehavior | Represents the filter behavior. |
System.Boolean | isCaseSensitive | Determines whether is in case sensitive. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Returns the 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)
Generates a predicate expression for the given values.
Declaration
public static Expression Predicate(this IQueryable source, ParameterExpression parameterExpression, string propertyName, object constantValue, FilterType filterType, FilterBehavior filterBehavior, bool isCaseSensitive, Type sourceType, Delegate expressionFunction)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | constantValue | The object. |
FilterType | filterType | The filter type. |
FilterBehavior | filterBehavior | The filter behavior. |
System.Boolean | isCaseSensitive | A boolean values indicating whether to consider the expression with case sensitive. |
System.Type | sourceType | The type of the source |
System.Delegate | expressionFunction | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | A predicate binary expression for the given values. |
Predicate(IQueryable, ParameterExpression, String, Object, FilterType, FilterBehavior, Boolean, Type, String)
Generates a predicate expression for the given values.
Declaration
public static Expression Predicate(this IQueryable source, ParameterExpression parameterExpression, string propertyName, object constantValue, FilterType filterType, FilterBehavior filterBehavior, bool isCaseSensitive, Type sourceType, string format)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | constantValue | The object. |
FilterType | filterType | The filter type. |
FilterBehavior | filterBehavior | The filter behavior. |
System.Boolean | isCaseSensitive | A boolean values indicating whether to consider the expression with case sensitive. |
System.Type | sourceType | The type of the source. |
System.String | format | Represents the current format. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | A predicate expression for the given values. |
Predicate(IQueryable, ParameterExpression, String, Object, Type, FilterType, FilterBehavior, Boolean, Type, Delegate)
Generates a predicate expression for the given values.
Declaration
public static Expression Predicate(this IQueryable source, ParameterExpression parameterExpression, string propertyName, object constantValue, Type memberType, FilterType filterType, FilterBehavior filterBehavior, bool isCaseSensitive, Type sourceType, Delegate expressionFunction)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.String | propertyName | The property name. |
System.Object | constantValue | The object. |
System.Type | memberType | The member type. |
FilterType | filterType | The filter type. |
FilterBehavior | filterBehavior | The filter behavior. |
System.Boolean | isCaseSensitive | A boolean values indicating whether to consider the expression with case sensitive. |
System.Type | sourceType | The type of the source |
System.Delegate | expressionFunction | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | A predicate binary expression for the given values. |
Select(IQueryable, IEnumerable<String>)
Generates a Select query based on the given source and the properties passed.
Declaration
public static IQueryable Select(this IQueryable source, IEnumerable<string> properties)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Collections.Generic.IEnumerable<System.String> | properties | The enumerable collection of properties. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A Select query based on the given source and the properties passed. |
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 | Represents the queryable source. |
System.Collections.Generic.IEnumerable<System.String> | properties | Represents the properties. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
Select(IQueryable, String)
Generates a Select query for the given source and property.
Declaration
public static IQueryable Select(this IQueryable source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name for which the query is generated. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A Select query for the given source and property. |
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 | Represents the queryable source. |
System.String | propertyName | Represents the property name. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns queryable objects. |
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 | Represents the queryable source. |
System.String[] | properties | Represents the properties. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns queryable objects. |
Skip(IQueryable, Int32)
Generates a SKIP expression for the given IQueryable source and the constant value.
Declaration
public static IQueryable Skip(this IQueryable source, int constValue)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Int32 | constValue | The constant value. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A SKIP expression for the given IQueryable source and the constant value. |
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 constant value. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns queryable objects. |
Sum(IQueryable, String)
Calculates the result by executing the expression obtained from the queryable sum method based on the given source and property name.
Declaration
public static object Sum(this IQueryable source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
Returns
Type | Description |
---|---|
System.Object | The result by executing the expression obtained from the queryable sum method based on the given source and property name. |
Sum(IQueryable, String, Expression<Func<String, Object, Object>>)
Calculates the result by executing the expression obtained from the queryable sum method based on the given source, property and the expression function.
Declaration
public static object Sum(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function. |
Returns
Type | Description |
---|---|
System.Object | The result by executing the expression obtained from the queryable sum method based on the given source, property and the expression function. |
Sum(IQueryable, String, Type)
Calculates the result by executing the expression obtained from the queryable sum method based on the given source type and property name.
Declaration
public static object Sum(this IQueryable source, string propertyName, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Type | sourceType | The type of the source. |
Returns
Type | Description |
---|---|
System.Object | The result by executing the expression obtained from the queryable sum method based on the given source type and property name. |
Take(IQueryable, Int32)
Generates a TAKE expression for the given IQueryable source and the constant value.
Declaration
public static IQueryable Take(this IQueryable source, int constValue)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Int32 | constValue | The constant value. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A TAKE expression for the given IQueryable source and the constant value. |
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 constant value. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
ThenBy(IQueryable, ParameterExpression, Expression)
Generates a ThenBy query expression for the given source and the expressions.
Declaration
public static IQueryable ThenBy(this IQueryable source, ParameterExpression parameterExpression, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.Linq.Expressions.Expression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A ThenBy query expression for the given source and the expressions. |
ThenBy(IQueryable, String)
Generates a ThenBy query expression for the given queryable source and property name.
Declaration
public static IQueryable ThenBy(this IQueryable source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A ThenBy query expression for the queryable source and property name. |
ThenBy(IQueryable, String, IComparer<Object>, Expression<Func<String, Object, Object>>)
Generates a ThenBy query expression for the given values.
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 | The IQueryable source. |
System.String | propertyName | The property name. |
System.Collections.Generic.IComparer<System.Object> | comparer | The comparer. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A ThenBy query expression for the given values. |
ThenBy(IQueryable, String, IComparer<Object>, Type)
Generates an ThenBy query expression for the given values.
Declaration
public static IQueryable ThenBy(this IQueryable source, string propertyName, IComparer<object> comparer, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Collections.Generic.IComparer<System.Object> | comparer | The comparer. |
System.Type | sourceType | The type of the source. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | An ThenBy query expression for the given values. |
ThenBy(IQueryable, String, Expression<Func<String, Object, Object>>)
Generates a ThenBy query expression for the given source, property and the expression function.
Declaration
public static IQueryable ThenBy(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A ThenBy query expression for the given source, property and the expression function. |
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 | Represents the queryable source. |
System.String | propertyName | Represents the property name. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
ThenBy<T>(IQueryable, IComparer<T>)
Generates an ThenBy query expression for the given source and the comparer for the given type.
Declaration
public static IQueryable ThenBy<T>(this IQueryable source, IComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Collections.Generic.IComparer<T> | comparer | The comparer. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | An ThenBy query expression for the given source and the comparer for the given type. |
Type Parameters
Name | Description |
---|---|
T | The type parameter. |
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 | Represents the queryable source. |
System.Collections.Generic.IComparer<T> | comparer | Represents the comparer. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
ThenByDescending(IQueryable, ParameterExpression, Expression)
Generates a ThenByDescending query expression for the given source and the expressions.
Declaration
public static IQueryable ThenByDescending(this IQueryable source, ParameterExpression parameterExpression, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Linq.Expressions.ParameterExpression | parameterExpression | The parameter expression. |
System.Linq.Expressions.Expression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A ThenByDescending query expression for the given source and the expressions. |
ThenByDescending(IQueryable, String)
Generates a ThenByDescending query for the given source and the property.
Declaration
public static IQueryable ThenByDescending(this IQueryable source, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source |
System.String | propertyName | The property name. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A ThenByDescending query for the given source and the property. |
ThenByDescending(IQueryable, String, IComparer<Object>, Expression<Func<String, Object, Object>>)
Generates a ThenByDescending query expression for the given values.
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 | The IQueryable source. |
System.String | propertyName | The property name. |
System.Collections.Generic.IComparer<System.Object> | comparer | The comparer. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A ThenByDescending query expression for the given values. |
ThenByDescending(IQueryable, String, IComparer<Object>, Type)
Generates an ThenByDescending query expression for the given values.
Declaration
public static IQueryable ThenByDescending(this IQueryable source, string propertyName, IComparer<object> comparer, Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Collections.Generic.IComparer<System.Object> | comparer | The comparer. |
System.Type | sourceType | The type of the source. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | An ThenByDescending query expression for the given values. |
ThenByDescending(IQueryable, String, Expression<Func<String, Object, Object>>)
Generates a ThenByDescending query expression for the given values.
Declaration
public static IQueryable ThenByDescending(this IQueryable source, string propertyName, Expression<Func<string, object, object>> expressionFunc)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The property name. |
System.Linq.Expressions.Expression<System.Func<System.String, System.Object, System.Object>> | expressionFunc | The expression function. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | A ThenByDescending query expression for the given values. |
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 | Represents the queryable source. |
System.String | propertyName | Represents the property name. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
ThenByDescending<T>(IQueryable, IComparer<T>)
Generates an ThenByDescending query expression for the given source and the comparer for the given type.
Declaration
public static IQueryable ThenByDescending<T>(this IQueryable source, IComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.Collections.Generic.IComparer<T> | comparer | The comparer. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | An ThenByDescending query expression for the given source and the comparer for the given type. |
Type Parameters
Name | Description |
---|---|
T | The type parameter. |
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 | Represents the source. |
System.Collections.Generic.IComparer<T> | comparer | Represents the comparer. |
System.Type | sourceType | Represents the source type. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
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 database = new DataClasses1DataContext();
var orders = database.Orders.Skip(0).Take(100).ToList();
var queryable = orders.AsQueryable();
var parameter = queryable.Parameter("ShipCountry");
var binaryExpression = queryable.Predicate(parameter,
"ShipCountry", "USA", true);
var filteredOrders = queryable.Where(parameter, binaryExpression);
foreach (var order in filteredOrders)
{
Console.WriteLine(order);
}
Build Predicates for Contains / StartsWith / EndsWith,
IQueryable queryable = model.Orders.AsQueryable();
var parameter = queryable.Parameter();
var expression1 = queryable.Predicate(parameter, "ShipCountry", "h", FilterType.Contains);
var expression2 = queryable.Predicate(parameter, "ShipCountry", "a", FilterType.StartsWith);
var andExpression = expression2.OrPredicate(expression1);
var filters = queryable.Where(parameter, andExpression);
foreach (Orders item in filters)
{
Console.WriteLine("{0}/{1}", item.OrderID, item.ShipCountry);
}
Declaration
public static IQueryable Where(this IQueryable source, ParameterExpression parameterExpression, Expression predicateExpression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | Represents the source. |
System.Linq.Expressions.ParameterExpression | parameterExpression | Represents the parameter expression. |
System.Linq.Expressions.Expression | predicateExpression | Represents the predicate expression. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |
Where(IQueryable, String, Object, FilterType, Boolean)
Generates the where expression for the given values.
Declaration
public static IQueryable Where(this IQueryable source, string propertyName, object value, FilterType filterType, bool isCaseSensitive)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | source | The IQueryable source. |
System.String | propertyName | The name of the property. |
System.Object | value | The object. |
FilterType | filterType | The filter type. |
System.Boolean | isCaseSensitive | A boolean value indicating whether the expression should be considered as case sensitive or not. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | The where expression for the given values. |
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 | Represents the queryable source. |
System.String | propertyName | Name of the property. |
System.Object | value | Represents the value. |
FilterType | filterType | Represents the filter value. |
System.Boolean | isCaseSensitive | Determines whether is in case sensitive. |
System.Type | sourceType | Represents the type of source. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable | Returns the queryable objects. |