Represents a typed query against a conceptual model in a given object context.
The example in this topic is based on the AdventureWorks Sales Model.
The example shows how to construct an instance of the ObjectQuery<T> class.
// Call the constructor with a query for products and the ObjectContext.
// Call the constructor with the specified query and the ObjectContext.
// and the NoTracking merge option.
' Call the constructor with a query for products and the ObjectContext.
Dim queryString As String = "SELECT VALUE product FROM AdventureWorksEntities.Products AS product"
' Call the constructor with the specified query and the ObjectContext.
' and the NoTracking merge option.
When it is acted upon, such as during a foreach (C#) or For Each (Visual Basic) enumeration.
When it is assigned to fill a List<T> collection.
When the Execute method is explicitly called.
The query itself can be created by using an Entity SQL statement or a LINQ query, or it can be incrementally built by using the query builder methods included in the class. In every case, the result is a new ObjectQuery<T> instance that, when explicitly executed or enumerated over, will send the query to the data source for execution and return the results.
An ObjectQuery<T> is frequently of an entity type, but it can also be of DbDataRecord type, for projections to an anonymous type, or of a primitive type, such as an integer or string. For more information, see Object Queries.
Creates a new ObjectQuery<T> instance using the specified Entity SQL command as the initial query.
Creates a new ObjectQuery<T> instance using the specified Entity SQL command as the initial query and the specified merge option.
Returns the command text for the query.
Gets the object context associated with this object query.
Gets or sets a value that indicates whether the query plan should be cached.
Gets a value that indicates whether the collection returned by the query contains collection objects.
Gets the result element type for this query instance.
Gets the expression describing this query.
Gets the LINQ IQueryProvider associated with this query instance.
Gets or sets how objects returned from a query are added to the object context.
Gets or sets the name of this object query.
Gets the parameter collection for this object query.
Limits the query to unique results.
Limits the query results by excluding results based on the results of another object query.
Executes the object query with the specified merge option.
Returns information about the result type of the query.
Groups the query results by the specified criteria.
Limits the query results by including only the results that exist in another object query.
Limits the query to only results of a specific type.
Orders the query results by the specified criteria.
Limits the query results to only the properties that are defined in the specified projection.
Limits the query results to only the property specified in the projection.
Orders the query results by the specified criteria and skips a specified number of results.
Limits the query results to a specified number of items.
Returns the commands to execute against the data source.
Combines the results of the query with the results of another object query, without any duplicates.
Combines the results of the query with the results of another object query, including all duplicates.
Limits the query to results that match specified filtering criteria.
Returns an enumerator that iterates through the results of the query.