Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ObjectContext::CreateQuery<T> Method

Creates an ObjectQuery<T> in the current object context by using the specified query string.

Namespace:  System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

public:
generic<typename T>
ObjectQuery<T>^ CreateQuery(
	String^ queryString, 
	... array<ObjectParameter^>^ parameters
)

Type Parameters

T

The entity type of the returned ObjectQuery<T>.

Parameters

queryString
Type: System::String

The query string to be executed.

parameters
Type: array<System.Data.Objects::ObjectParameter>

Parameters to pass to the query.

Return Value

Type: System.Data.Objects::ObjectQuery<T>
An ObjectQuery<T> of the specified type.

ExceptionCondition
ArgumentNullException

The queryString or parameters parameter is nullptr.

Use CreateQuery<T> to create an ObjectQuery<T> of the specified type that belongs to the current object context.

This example is based on the Adventure Works Sales Model.

The example creates a simple query and iterates through the collection of results.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4
Show:
© 2015 Microsoft