IQueryProvider.CreateQuery Method

Definition

Overloads

CreateQuery(Expression)

Constructs an IQueryable object that can evaluate the query represented by a specified expression tree.

CreateQuery<TElement>(Expression)

Constructs an IQueryable<T> object that can evaluate the query represented by a specified expression tree.

CreateQuery(Expression)

Constructs an IQueryable object that can evaluate the query represented by a specified expression tree.

C#
public System.Linq.IQueryable CreateQuery(System.Linq.Expressions.Expression expression);

Parameters

expression
Expression

An expression tree that represents a LINQ query.

Returns

An IQueryable that can evaluate the query represented by the specified expression tree.

Remarks

Note

The Expression property of the returned IQueryable object is equal to expression.

The CreateQuery method is used to create new IQueryable objects, given an expression tree. The query that is represented by the returned object is associated with a specific LINQ provider.

Several of the standard query operator methods defined in Queryable, such as OfType and Cast, call this method. They pass it a MethodCallExpression that represents a LINQ query.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

CreateQuery<TElement>(Expression)

Constructs an IQueryable<T> object that can evaluate the query represented by a specified expression tree.

C#
public System.Linq.IQueryable<TElement> CreateQuery<TElement>(System.Linq.Expressions.Expression expression);

Type Parameters

TElement

The type of the elements of the IQueryable<T> that is returned.

Parameters

expression
Expression

An expression tree that represents a LINQ query.

Returns

IQueryable<TElement>

An IQueryable<T> that can evaluate the query represented by the specified expression tree.

Remarks

Note

The Expression property of the returned IQueryable<T> object is equal to expression.

The CreateQuery method is used to create new IQueryable<T> objects, given an expression tree. The query that is represented by the returned object is associated with a specific LINQ provider.

Most of the Queryable standard query operator methods that return enumerable results call this method. They pass it a MethodCallExpression that represents a LINQ query.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0