Class QueryBuilder
Used to build up a Queryable.
public class QueryBuilder
- Inheritance
-
QueryBuilder
- Inherited Members
Methods
ApplyOrderBy(IQueryable, Type, OrderByClause)
Apply an orderBy clause, using OrderBy for the first term and ThenBy for the rest.
public static IQueryable ApplyOrderBy(IQueryable source, Type elementType, OrderByClause orderByClause)
Parameters
sourceIQueryableThe queryable to sort.
elementTypeTypeThe element type of the queryable.
orderByClauseOrderByClauseThe validated orderBy clause.
Returns
- IQueryable
The sorted queryable.
Exceptions
- Exception
A sort path does not resolve to a property.
ApplySelect(IQueryable, Type, SelectClause)
Apply a select clause, projecting onto a type generated to hold exactly the selected properties.
public static IQueryable ApplySelect(IQueryable source, Type elementType, SelectClause selectClause)
Parameters
sourceIQueryableThe queryable to project.
elementTypeTypeThe element type of the queryable.
selectClauseSelectClauseThe validated select clause.
Returns
- IQueryable
A queryable over the generated projection type.
ApplySkip(IQueryable, Type, int)
Apply Queryable.Skip for the element type.
public static IQueryable ApplySkip(IQueryable source, Type elementType, int skipCount)
Parameters
sourceIQueryableThe queryable to skip within.
elementTypeTypeThe element type of the queryable.
skipCountintThe number of rows to skip.
Returns
- IQueryable
The queryable with Skip applied.
ApplyTake(IQueryable, Type, int)
Apply Queryable.Take for the element type.
public static IQueryable ApplyTake(IQueryable source, Type elementType, int takeCount)
Parameters
sourceIQueryableThe queryable to limit.
elementTypeTypeThe element type of the queryable.
takeCountintThe number of rows to take.
Returns
- IQueryable
The queryable with Take applied.
ApplyWhere(IQueryable, Type, BasePredicate)
Apply a where clause by building the Queryable.Where call for the element type.
public static IQueryable ApplyWhere(IQueryable source, Type elementType, BasePredicate predicate)
Parameters
sourceIQueryableThe queryable to filter.
elementTypeTypeThe element type of the queryable.
predicateBasePredicateThe validated where clause.
Returns
- IQueryable
The filtered queryable.
BuildIQueryableFunc(Type, MethodInfo)
Compile a delegate that calls a one-argument Queryable method on an untyped IQueryable.
public static Func<IQueryable, IQueryable> BuildIQueryableFunc(Type instanceType, MethodInfo method)
Parameters
instanceTypeTypeThe element type to close the method over.
methodMethodInfoThe Queryable method to call.
Returns
- Func<IQueryable, IQueryable>
A delegate applying that method.
Remarks
The Queryable methods are generic, but the element type is only known at runtime, so the call is built as an expression - casting in to IQueryable<T> and back out again - and compiled.
BuildIQueryableFunc<TArg>(Type, MethodInfo, TArg, Type?)
Compile a delegate that calls a two-argument Queryable method on an untyped IQueryable, with the second argument fixed.
public static Func<IQueryable, IQueryable> BuildIQueryableFunc<TArg>(Type instanceType, MethodInfo method, TArg parameter, Type? queryableBaseType = null)
Parameters
instanceTypeTypeThe element type to close the method over.
methodMethodInfoThe Queryable method to call.
parameterTArgThe value passed as the method's second argument.
queryableBaseTypeTypeThe interface to cast the source to; defaults to IQueryable<T>, and is IOrderedQueryable<T> for ThenBy.
Returns
- Func<IQueryable, IQueryable>
A delegate applying that method.
Type Parameters
TArgThe type of the fixed argument - a lambda for Where and OrderBy, an int for Skip and Take.