Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
1065 lines (901 sloc) 80.7 KB
<Type Name="ObjectQuery&lt;T&gt;" FullName="System.Data.Objects.ObjectQuery&lt;T&gt;">
<TypeSignature Language="C#" Value="public class ObjectQuery&lt;T&gt; : System.Data.Objects.ObjectQuery, System.Collections.Generic.IEnumerable&lt;T&gt;, System.ComponentModel.IListSource, System.Linq.IOrderedQueryable&lt;T&gt;, System.Linq.IQueryable&lt;T&gt;" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ObjectQuery`1&lt;T&gt; extends System.Data.Objects.ObjectQuery implements class System.Collections.Generic.IEnumerable`1&lt;!T&gt;, class System.Collections.IEnumerable, class System.ComponentModel.IListSource, class System.Linq.IOrderedQueryable, class System.Linq.IOrderedQueryable`1&lt;!T&gt;, class System.Linq.IQueryable, class System.Linq.IQueryable`1&lt;!T&gt;" />
<TypeSignature Language="DocId" Value="T:System.Data.Objects.ObjectQuery`1" />
<TypeSignature Language="VB.NET" Value="Public Class ObjectQuery(Of T)&#xA;Inherits ObjectQuery&#xA;Implements IEnumerable(Of T), IListSource, IOrderedQueryable(Of T), IQueryable(Of T)" />
<TypeSignature Language="C++ CLI" Value="generic &lt;typename T&gt;&#xA;public ref class ObjectQuery : System::Data::Objects::ObjectQuery, System::Collections::Generic::IEnumerable&lt;T&gt;, System::ComponentModel::IListSource, System::Linq::IOrderedQueryable&lt;T&gt;, System::Linq::IQueryable&lt;T&gt;" />
<TypeSignature Language="F#" Value="type ObjectQuery&lt;'T&gt; = class&#xA; inherit ObjectQuery&#xA; interface seq&lt;'T&gt;&#xA; interface IEnumerable&#xA; interface IQueryable&lt;'T&gt;&#xA; interface IQueryable&#xA; interface IOrderedQueryable&lt;'T&gt;&#xA; interface IOrderedQueryable&#xA; interface IListSource" />
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeParameters>
<TypeParameter Name="T" />
</TypeParameters>
<Base>
<BaseTypeName>System.Data.Objects.ObjectQuery</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.Collections.Generic.IEnumerable&lt;T&gt;</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.IEnumerable</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.ComponentModel.IListSource</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Linq.IOrderedQueryable</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Linq.IOrderedQueryable&lt;T&gt;</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Linq.IQueryable</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Linq.IQueryable&lt;T&gt;</InterfaceName>
</Interface>
</Interfaces>
<Docs>
<typeparam name="T">The entity type of the query.</typeparam>
<summary>Represents a typed query against a conceptual model in a given object context.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Data.Objects.ObjectQuery%601> generic class represents a query that returns a collection of zero or more objects of a specific type. The <xref:System.Data.Objects.ObjectContext> must be defined before an object query can be executed. This context provides the connection and metadata information that is required to compose and execute the query. An object query is executed in the following scenarios:
- When it is acted upon, such as during a `foreach` (C#) or `For Each` (Visual Basic) enumeration.
- When it is assigned to fill a <xref:System.Collections.Generic.List%601> collection.
- When the <xref:System.Data.Objects.ObjectQuery%601.Execute%2A> method is explicitly called.
The query itself can be created by using an [!INCLUDE[esql](~/includes/esql-md.md)] 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 <xref:System.Data.Objects.ObjectQuery%601> instance that, when explicitly executed or enumerated over, will send the query to the data source for execution and return the results.
An <xref:System.Data.Objects.ObjectQuery%601> is frequently of an entity type, but it can also be of <xref:System.Data.Common.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](https://msdn.microsoft.com/library/0768033c-876f-471d-85d5-264884349276).
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832).
The example shows how to construct an instance of the <xref:System.Data.Objects.ObjectQuery%601> class.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery)]
]]></format>
</remarks>
<related type="Article" href="https://msdn.microsoft.com/library/9e7d8837-28c5-429d-a824-7bafb59724cf">Entity SQL Language</related>
<related type="Article" href="https://msdn.microsoft.com/library/641f9b68-9046-47a1-abb0-1c8eaeda0e2d">LINQ to Entities</related>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Data.Objects.ObjectQuery`1" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
An <xref:System.Data.Objects.ObjectQuery%601> can be initialized in such a way that it represents a single scalar result and not a collection of scalar results. Some extension methods require collection results as input. In this case, an <xref:System.ArgumentException> is thrown when one of these methods is called. For more information, see [Object Queries](https://msdn.microsoft.com/library/0768033c-876f-471d-85d5-264884349276).
When your application generates Entity SQL queries at runtime, you should be aware of any command length limitations of the data source. Entity SQL does not enforce limitations on the length of the command text in queries.
]]></format>
</remarks>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects and Shaping Results (Entity Framework)</related>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ObjectQuery (string commandText, System.Data.Objects.ObjectContext context);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string commandText, class System.Data.Objects.ObjectContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.#ctor(System.String,System.Data.Objects.ObjectContext)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (commandText As String, context As ObjectContext)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; ObjectQuery(System::String ^ commandText, System::Data::Objects::ObjectContext ^ context);" />
<MemberSignature Language="F#" Value="new System.Data.Objects.ObjectQuery&lt;'T&gt; : string * System.Data.Objects.ObjectContext -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="new System.Data.Objects.ObjectQuery&lt;'T&gt; (commandText, context)" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="commandText" Type="System.String" />
<Parameter Name="context" Type="System.Data.Objects.ObjectContext" />
</Parameters>
<Docs>
<param name="commandText">The [!INCLUDE[esql](~/includes/esql-md.md)] query.</param>
<param name="context">The <see cref="T:System.Data.Objects.ObjectContext" /> on which to execute the query.</param>
<summary>Creates a new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance using the specified [!INCLUDE[esql](~/includes/esql-md.md)] command as the initial query.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When your application generates Entity SQL queries at runtime, you should be aware of any command length limitations of the data source. Entity SQL does not enforce limitations on the length of the command text in queries.
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example shows how to construct an instance of the <xref:System.Data.Objects.ObjectQuery%601> class.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery)]
]]></format>
</remarks>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ObjectQuery (string commandText, System.Data.Objects.ObjectContext context, System.Data.Objects.MergeOption mergeOption);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string commandText, class System.Data.Objects.ObjectContext context, valuetype System.Data.Objects.MergeOption mergeOption) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.#ctor(System.String,System.Data.Objects.ObjectContext,System.Data.Objects.MergeOption)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; ObjectQuery(System::String ^ commandText, System::Data::Objects::ObjectContext ^ context, System::Data::Objects::MergeOption mergeOption);" />
<MemberSignature Language="F#" Value="new System.Data.Objects.ObjectQuery&lt;'T&gt; : string * System.Data.Objects.ObjectContext * System.Data.Objects.MergeOption -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="new System.Data.Objects.ObjectQuery&lt;'T&gt; (commandText, context, mergeOption)" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="commandText" Type="System.String" />
<Parameter Name="context" Type="System.Data.Objects.ObjectContext" />
<Parameter Name="mergeOption" Type="System.Data.Objects.MergeOption" />
</Parameters>
<Docs>
<param name="commandText">The [!INCLUDE[esql](~/includes/esql-md.md)] query.</param>
<param name="context">The <see cref="T:System.Data.Objects.ObjectContext" /> on which to execute the query.</param>
<param name="mergeOption">Specifies how the entities that are retrieved through this query should be merged with the entities that have been returned from previous queries against the same <see cref="T:System.Data.Objects.ObjectContext" />.</param>
<summary>Creates a new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance using the specified [!INCLUDE[esql](~/includes/esql-md.md)] command as the initial query and the specified merge option.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When your application generates Entity SQL queries at runtime, you should be aware of any command length limitations of the data source. Entity SQL does not enforce limitations on the length of the command text in queries.
## Examples
This example is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The <xref:System.Data.Objects.ObjectQuery%601> is initialized with the specified query, <xref:System.Data.Objects.ObjectContext>, and <xref:System.Data.Objects.MergeOption>.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Select](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_select)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Select](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_select)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Distinct">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; Distinct ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; Distinct() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Distinct" />
<MemberSignature Language="VB.NET" Value="Public Function Distinct () As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ Distinct();" />
<MemberSignature Language="F#" Value="member this.Distinct : unit -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.Distinct " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Limits the query to unique results.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/select-entity-sql">SELECT DISTINCT</see> applied.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This query builder method returns an <xref:System.Data.Objects.ObjectQuery%601> instance that is equivalent to the original query with [SELECT DISTINCT](~/docs/framework/data/adonet/ef/language-reference/select-entity-sql.md) applied.
The `DISTINCT` operator cannot be applied to an object that includes a mapping to a non-comparable column in the data source (such as ntext).
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example uses <xref:System.Data.Objects.ObjectQuery%601.UnionAll%2A> method to create a new <xref:System.Data.Objects.ObjectQuery%601> object. Then it calls <xref:System.Data.Objects.ObjectQuery%601.Distinct%2A> on the new <xref:System.Data.Objects.ObjectQuery%601> object to get the unique results of this query.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Distinct_UnionAll](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_distinct_unionall)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Distinct_UnionAll](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_distinct_unionall)]
]]></format>
</remarks>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Except">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; Except (System.Data.Objects.ObjectQuery&lt;T&gt; query);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; Except(class System.Data.Objects.ObjectQuery`1&lt;!T&gt; query) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Except(System.Data.Objects.ObjectQuery{`0})" />
<MemberSignature Language="VB.NET" Value="Public Function Except (query As ObjectQuery(Of T)) As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ Except(System::Data::Objects::ObjectQuery&lt;T&gt; ^ query);" />
<MemberSignature Language="F#" Value="member this.Except : System.Data.Objects.ObjectQuery&lt;'T&gt; -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.Except query" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="query" Type="System.Data.Objects.ObjectQuery&lt;T&gt;" />
</Parameters>
<Docs>
<param name="query">An <see cref="T:System.Data.Objects.ObjectQuery`1" /> that represents the results to exclude from the query.</param>
<summary>Limits the query results by excluding results based on the results of another object query.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/except-entity-sql">EXCEPT</see> applied based on the specified <paramref name="query" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The supplied `query` that defines results to exclude must be of the same type or of a type that is compatible with the <xref:System.Data.Objects.ObjectQuery%601>.
Parameters that are defined in the supplied `query` are merged with parameters that are defined in the <xref:System.Data.Objects.ObjectQuery%601> instance. Parameters must be unique in the combined <xref:System.Data.Objects.ObjectParameterCollection>. There cannot be two parameters in the combined collection with the same name. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
The resulting query inherits the connection from the <xref:System.Data.Objects.ObjectQuery%601> instance on which <xref:System.Data.Objects.ObjectQuery%601.Except%2A> was called.
## Examples
This example is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example uses <xref:System.Data.Objects.ObjectQuery%601.Except%2A> method to create a new <xref:System.Data.Objects.ObjectQuery%601> object and then iterates through the result of the new query.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Except](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_except)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Except](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_except)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="query" /> parameter is <see langword="null" /> or an empty string.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects and Shaping Results (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Execute">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectResult&lt;T&gt; Execute (System.Data.Objects.MergeOption mergeOption);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectResult`1&lt;!T&gt; Execute(valuetype System.Data.Objects.MergeOption mergeOption) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Execute(System.Data.Objects.MergeOption)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectResult&lt;T&gt; ^ Execute(System::Data::Objects::MergeOption mergeOption);" />
<MemberSignature Language="F#" Value="override this.Execute : System.Data.Objects.MergeOption -&gt; System.Data.Objects.ObjectResult&lt;'T&gt;" Usage="objectQuery.Execute mergeOption" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectResult&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="mergeOption" Type="System.Data.Objects.MergeOption" />
</Parameters>
<Docs>
<param name="mergeOption">The <see cref="T:System.Data.Objects.MergeOption" /> to use when executing the query. The default is <see cref="F:System.Data.Objects.MergeOption.AppendOnly" />.</param>
<summary>Executes the object query with the specified merge option.</summary>
<returns>An <see cref="T:System.Data.Objects.ObjectResult`1" /> that contains a collection of entity objects returned by the query.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The default merge option for object queries is <xref:System.Data.Objects.MergeOption.AppendOnly>. For more information, see [Identity Resolution, State Management, and Change Tracking](https://msdn.microsoft.com/library/3bd49311-0e72-4ea4-8355-38fe57036ba0).
## Examples
This example is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example returns an <xref:System.Data.Objects.ObjectResult%601> from <xref:System.Data.Objects.ObjectQuery.Execute%2A> method. Then it gets an enumerator and iterates through the query results. At the end it releases the enumerator and the <xref:System.Data.Objects.ObjectResult%601> object.
[!code-csharp[DP ObjectServices Concepts#QueryResult](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#queryresult)]
[!code-vb[DP ObjectServices Concepts#QueryResult](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#queryresult)]
]]></format>
</remarks>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="GroupBy">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;System.Data.Common.DbDataRecord&gt; GroupBy (string keys, string projection, params System.Data.Objects.ObjectParameter[] parameters);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;class System.Data.Common.DbDataRecord&gt; GroupBy(string keys, string projection, class System.Data.Objects.ObjectParameter[] parameters) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.GroupBy(System.String,System.String,System.Data.Objects.ObjectParameter[])" />
<MemberSignature Language="VB.NET" Value="Public Function GroupBy (keys As String, projection As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of DbDataRecord)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;System::Data::Common::DbDataRecord ^&gt; ^ GroupBy(System::String ^ keys, System::String ^ projection, ... cli::array &lt;System::Data::Objects::ObjectParameter ^&gt; ^ parameters);" />
<MemberSignature Language="F#" Value="member this.GroupBy : string * string * System.Data.Objects.ObjectParameter[] -&gt; System.Data.Objects.ObjectQuery&lt;System.Data.Common.DbDataRecord&gt;" Usage="objectQuery.GroupBy (keys, projection, parameters)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;System.Data.Common.DbDataRecord&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="keys" Type="System.String" />
<Parameter Name="projection" Type="System.String" />
<Parameter Name="parameters" Type="System.Data.Objects.ObjectParameter[]">
<Attributes>
<Attribute FrameworkAlternate="netframework-3.5">
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="keys">The key columns by which to group the results.</param>
<param name="projection">The list of selected properties that defines the projection.</param>
<param name="parameters">Zero or more parameters that are used in this method.</param>
<summary>Groups the query results by the specified criteria.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance of type <see cref="T:System.Data.Common.DbDataRecord" /> that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/group-by-entity-sql">GROUP BY</see> applied.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Data.Objects.ObjectQuery%601.GroupBy%2A> applies the projection specified by the `projection` parameter. This means that the <xref:System.Data.Objects.ObjectQuery%601> returned by the <xref:System.Data.Objects.ObjectQuery%601.GroupBy%2A> method is always of type <xref:System.Data.Common.DbDataRecord>. For more information, see [Object Queries](https://msdn.microsoft.com/library/0768033c-876f-471d-85d5-264884349276).
## Examples
This example is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832).
This example creates a new <xref:System.Data.Objects.ObjectQuery%601> object that contains the results of the existing query grouped by product name.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_GroupBy](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_groupby)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_GroupBy](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_groupby)]
This example returns a set of nested data records that contain the `Contact.LastName` column, grouped and sorted alphabetically by the first letter of `Contact.LastName`.
[!code-csharp[DP ObjectServices Concepts#Projection_GroupBy](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#projection_groupby)]
[!code-vb[DP ObjectServices Concepts#Projection_GroupBy](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#projection_groupby)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="query" /> parameter is <see langword="null" /> or an empty string.
-or-
The <paramref name="projection" /> parameter is <see langword="null" /> or an empty string.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Include">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; Include (string path);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; Include(string path) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Include(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function Include (path As String) As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ Include(System::String ^ path);" />
<MemberSignature Language="F#" Value="member this.Include : string -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.Include path" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<param name="path">Dot-separated list of related objects to return in the query results.</param>
<summary>Specifies the related objects to include in the query results.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> with the defined query path.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Query paths can be used with Entity SQL and LINQ queries.
Paths are all-inclusive. For example, if an include call indicates `Include("Orders.OrderLines")`, not only will `OrderLines` be included, but also `Orders`. For more information, see [Loading Related Objects](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/bb896272(v=vs.100)).
When you call the <xref:System.Data.Objects.ObjectQuery%601.Include%2A> method, the query path is only valid on the returned instance of the <xref:System.Data.Objects.ObjectQuery%601>. Other instances of <xref:System.Data.Objects.ObjectQuery%601> and the object context itself are not affected.
Because the <xref:System.Data.Objects.ObjectQuery%601.Include%2A> method returns the query object, you can call this method multiple times on an <xref:System.Data.Objects.ObjectQuery%601> to specify multiple paths for the query, as in the following example:
[!code-csharp[DP ObjectServices Concepts#SpanOnlyWithMultiplePaths](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#spanonlywithmultiplepaths)]
[!code-vb[DP ObjectServices Concepts#SpanOnlyWithMultiplePaths](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#spanonlywithmultiplepaths)]
## Examples
[!code-csharp[DP ObjectServices Concepts#QueryWithSpan](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#querywithspan)]
[!code-vb[DP ObjectServices Concepts#QueryWithSpan](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#querywithspan)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="path" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="path" /> is <see langword="empty" />.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Intersect">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; Intersect (System.Data.Objects.ObjectQuery&lt;T&gt; query);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; Intersect(class System.Data.Objects.ObjectQuery`1&lt;!T&gt; query) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Intersect(System.Data.Objects.ObjectQuery{`0})" />
<MemberSignature Language="VB.NET" Value="Public Function Intersect (query As ObjectQuery(Of T)) As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ Intersect(System::Data::Objects::ObjectQuery&lt;T&gt; ^ query);" />
<MemberSignature Language="F#" Value="member this.Intersect : System.Data.Objects.ObjectQuery&lt;'T&gt; -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.Intersect query" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="query" Type="System.Data.Objects.ObjectQuery&lt;T&gt;" />
</Parameters>
<Docs>
<param name="query">An <see cref="T:System.Data.Objects.ObjectQuery`1" /> that represents the results to include in the query.</param>
<summary>Limits the query results by including only the results that exist in another object query.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/intersect-entity-sql">INTERSECT</see> applied based on the specified <paramref name="query" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The supplied `query` that defines results to include must be of the same type or of a type that is compatible with the <xref:System.Data.Objects.ObjectQuery%601>.
Parameters that are defined in the supplied `query` are merged with parameters that are defined in the <xref:System.Data.Objects.ObjectQuery%601> instance. Parameters must be unique in the combined <xref:System.Data.Objects.ObjectParameterCollection>. There cannot be two parameters in the combined collection with the same name. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
The resulting query inherits the connection from the <xref:System.Data.Objects.ObjectQuery%601> instance on which the <xref:System.Data.Objects.ObjectQuery%601.Intersect%2A> method was called.
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). This example creates a new <xref:System.Data.Objects.ObjectQuery%601> object that contains the results of two other queries.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Intersect](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_intersect)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Intersect](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_intersect)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="query" /> parameter is <see langword="null" /> or is an empty string.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Name">
<MemberSignature Language="C#" Value="public string Name { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Name" />
<MemberSignature Language="DocId" Value="P:System.Data.Objects.ObjectQuery`1.Name" />
<MemberSignature Language="VB.NET" Value="Public Property Name As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };" />
<MemberSignature Language="F#" Value="member this.Name : string with get, set" Usage="System.Data.Objects.ObjectQuery&lt;'T&gt;.Name" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the name of this object query.</summary>
<value>A <see langword="string" /> value that is the name of this <see cref="T:System.Data.Objects.ObjectQuery`1" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The name of the object query identifies the current object query in the sequence by name when constructing query builder methods. By default, the query name is `it`. This can be useful when referring to the current sequence in joins inside the <xref:System.Data.Objects.ObjectQuery`1.Where*> method or in the <xref:System.Data.Objects.ObjectQuery`1.SelectValue*> method. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
When you set the <xref:System.Data.Objects.ObjectQuery%601.Name%2A> property of an <xref:System.Data.Objects.ObjectQuery%601>, that value becomes the alias in successive methods.
The value of the <xref:System.Data.Objects.ObjectQuery%601.Name%2A> property must start with a letter and can contain letters, digits, and underscores.
## Examples
This example sets the name of the first <xref:System.Data.Objects.ObjectQuery%601> to "product" and then uses this alias in the successive <xref:System.Data.Objects.ObjectQuery%601.OrderBy%2A> method. The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832).
[!code-csharp[DP ObjectServices Concepts#QueryWithAliasNamed](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#querywithaliasnamed)]
[!code-vb[DP ObjectServices Concepts#QueryWithAliasNamed](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#querywithaliasnamed)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">The value specified on set is not valid.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="OfType&lt;TResultType&gt;">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;TResultType&gt; OfType&lt;TResultType&gt; ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!!TResultType&gt; OfType&lt;TResultType&gt;() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.OfType``1" />
<MemberSignature Language="VB.NET" Value="Public Function OfType(Of TResultType) () As ObjectQuery(Of TResultType)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA;generic &lt;typename TResultType&gt;&#xA; System::Data::Objects::ObjectQuery&lt;TResultType&gt; ^ OfType();" />
<MemberSignature Language="F#" Value="member this.OfType : unit -&gt; System.Data.Objects.ObjectQuery&lt;'ResultType&gt;" Usage="objectQuery.OfType " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;TResultType&gt;</ReturnType>
</ReturnValue>
<TypeParameters>
<TypeParameter Name="TResultType" />
</TypeParameters>
<Parameters />
<Docs>
<typeparam name="TResultType">The type of the <see cref="T:System.Data.Objects.ObjectResult`1" /> returned when the query is executed with the applied filter.</typeparam>
<summary>Limits the query to only results of a specific type.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/oftype-entity-sql">OFTYPE</see> applied.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Data.Objects.ObjectQuery`1.OfType*> is used to filter query results by a specific entity or complex type. This supports a conceptual model with object inheritance. For more information, see [Entity Data Model: Inheritance](~/docs/framework/data/adonet/entity-data-model-inheritance.md).
The <xref:System.Data.Objects.ObjectQuery`1.OfType*> method can only be applied to an <xref:System.Data.Objects.ObjectQuery%601> of an entity type or complex type that is defined in the EDM.
]]></format>
</remarks>
<exception cref="T:System.Data.EntitySqlException">The type specified is not valid.</exception>
<related type="Article" href="https://msdn.microsoft.com/library/be01614e-070e-41be-9746-bb674b41e488(v=vs.90)">How to: Create and Execute Object Queries using Table-per-Hierarchy Inheritance (Entity Framework)</related>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="OrderBy">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; OrderBy (string keys, params System.Data.Objects.ObjectParameter[] parameters);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; OrderBy(string keys, class System.Data.Objects.ObjectParameter[] parameters) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.OrderBy(System.String,System.Data.Objects.ObjectParameter[])" />
<MemberSignature Language="VB.NET" Value="Public Function OrderBy (keys As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ OrderBy(System::String ^ keys, ... cli::array &lt;System::Data::Objects::ObjectParameter ^&gt; ^ parameters);" />
<MemberSignature Language="F#" Value="member this.OrderBy : string * System.Data.Objects.ObjectParameter[] -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.OrderBy (keys, parameters)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="keys" Type="System.String" />
<Parameter Name="parameters" Type="System.Data.Objects.ObjectParameter[]">
<Attributes>
<Attribute FrameworkAlternate="netframework-3.5">
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="keys">The key columns by which to order the results.</param>
<param name="parameters">Zero or more parameters that are used in this method.</param>
<summary>Orders the query results by the specified criteria.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/order-by-entity-sql">ORDER BY</see> applied.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The ordering of results in a nested query cannot be guaranteed.
<xref:System.Data.Objects.ObjectQuery%601.OrderBy%2A> should always be the final query builder method in the sequence.
## Examples
This example is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example creates a new <xref:System.Data.Objects.ObjectQuery%601> object that contains the results of the existing query order by `ProductID`.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_OrderBy](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_orderby)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_OrderBy](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_orderby)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="keys" /> or <paramref name="parameters" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="key" /> is an empty string.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Select">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;System.Data.Common.DbDataRecord&gt; Select (string projection, params System.Data.Objects.ObjectParameter[] parameters);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;class System.Data.Common.DbDataRecord&gt; Select(string projection, class System.Data.Objects.ObjectParameter[] parameters) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Select(System.String,System.Data.Objects.ObjectParameter[])" />
<MemberSignature Language="VB.NET" Value="Public Function Select (projection As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of DbDataRecord)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;System::Data::Common::DbDataRecord ^&gt; ^ Select(System::String ^ projection, ... cli::array &lt;System::Data::Objects::ObjectParameter ^&gt; ^ parameters);" />
<MemberSignature Language="F#" Value="member this.Select : string * System.Data.Objects.ObjectParameter[] -&gt; System.Data.Objects.ObjectQuery&lt;System.Data.Common.DbDataRecord&gt;" Usage="objectQuery.Select (projection, parameters)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;System.Data.Common.DbDataRecord&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="projection" Type="System.String" />
<Parameter Name="parameters" Type="System.Data.Objects.ObjectParameter[]">
<Attributes>
<Attribute FrameworkAlternate="netframework-3.5">
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="projection">The list of selected properties that defines the projection.</param>
<param name="parameters">Zero or more parameters that are used in this method.</param>
<summary>Limits the query results to only the properties that are defined in the specified projection.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance of type <see cref="T:System.Data.Common.DbDataRecord" /> that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/select-entity-sql">SELECT</see> applied.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Data.Objects.ObjectQuery%601.Select%2A> applies the projection specified by the `projection` parameter. The <xref:System.Data.Objects.ObjectQuery%601> returned by the <xref:System.Data.Objects.ObjectQuery%601.Select%2A> method is always a row type of <xref:System.Data.Common.DbDataRecord>. Use the <xref:System.Data.Objects.ObjectQuery`1.SelectValue*> method to return values that are simple types, entity types, or complex types. For more information, see [LINQ to Entities](~/docs/framework/data/adonet/ef/language-reference/linq-to-entities.md).
When a navigation property is included in the projection, the query results include a collection of nested <xref:System.Data.Common.DbDataRecord> objects. For more information, see [How to: Navigate Relationships Using Navigation Properties](https://msdn.microsoft.com/library/b1d71c7d-16a7-4b46-96ac-690176bd5057).
## Examples
This example is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example creates a new <xref:System.Data.Objects.ObjectQuery%601> whose results are data records that contain the `ProductID` fields of the results of this query.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Select](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_select)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Select](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_select)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="projection" /> is <see langword="null" />.
-or-
<paramref name="parameters" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="projection" /> is an empty string.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="SelectValue&lt;TResultType&gt;">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;TResultType&gt; SelectValue&lt;TResultType&gt; (string projection, params System.Data.Objects.ObjectParameter[] parameters);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!!TResultType&gt; SelectValue&lt;TResultType&gt;(string projection, class System.Data.Objects.ObjectParameter[] parameters) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.SelectValue``1(System.String,System.Data.Objects.ObjectParameter[])" />
<MemberSignature Language="VB.NET" Value="Public Function SelectValue(Of TResultType) (projection As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of TResultType)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA;generic &lt;typename TResultType&gt;&#xA; System::Data::Objects::ObjectQuery&lt;TResultType&gt; ^ SelectValue(System::String ^ projection, ... cli::array &lt;System::Data::Objects::ObjectParameter ^&gt; ^ parameters);" />
<MemberSignature Language="F#" Value="member this.SelectValue : string * System.Data.Objects.ObjectParameter[] -&gt; System.Data.Objects.ObjectQuery&lt;'ResultType&gt;" Usage="objectQuery.SelectValue (projection, parameters)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;TResultType&gt;</ReturnType>
</ReturnValue>
<TypeParameters>
<TypeParameter Name="TResultType" />
</TypeParameters>
<Parameters>
<Parameter Name="projection" Type="System.String" />
<Parameter Name="parameters" Type="System.Data.Objects.ObjectParameter[]">
<Attributes>
<Attribute FrameworkAlternate="netframework-3.5">
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<typeparam name="TResultType">The type of the <see cref="T:System.Data.Objects.ObjectQuery`1" /> returned by the <see cref="M:System.Data.Objects.ObjectQuery`1.SelectValue``1(System.String,System.Data.Objects.ObjectParameter[])" /> method.</typeparam>
<param name="projection">The projection list.</param>
<param name="parameters">An optional set of query parameters that should be in scope when parsing.</param>
<summary>Limits the query results to only the property specified in the projection.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance of a type compatible with the specific projection. The returned <see cref="T:System.Data.Objects.ObjectQuery`1" /> is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/select-entity-sql">SELECT VALUE</see> applied.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Data.Objects.ObjectQuery`1.SelectValue*> is used to return values that are simple types, entity types, or complex types. Use the <xref:System.Data.Objects.ObjectQuery%601.Select%2A> method for projections that require a row type instead of a value type. For more information, see [Object Queries](https://msdn.microsoft.com/library/0768033c-876f-471d-85d5-264884349276).
The <xref:System.Data.Objects.ObjectQuery`1.SelectValue*> method applies the projection specified by the `projection` parameter. The <xref:System.Data.Objects.ObjectQuery%601> returned by the <xref:System.Data.Objects.ObjectQuery`1.SelectValue*> method must be of a value type that is compatible with the projection and must be the same type as the type of <xref:System.Data.Objects.ObjectQuery`1.SelectValue*>.
## Examples
This example is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example creates a new <xref:System.Data.Objects.ObjectQuery%601> that contains results that are a sequence of `ProductID` values projected from the results of the existing query.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_SelectValue](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_selectvalue)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_SelectValue](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_selectvalue)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="projection" /> is <see langword="null" />.
-or-
<paramref name="parameters" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="projection" /> is an empty string.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Skip">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; Skip (string keys, string count, params System.Data.Objects.ObjectParameter[] parameters);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; Skip(string keys, string count, class System.Data.Objects.ObjectParameter[] parameters) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Skip(System.String,System.String,System.Data.Objects.ObjectParameter[])" />
<MemberSignature Language="VB.NET" Value="Public Function Skip (keys As String, count As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ Skip(System::String ^ keys, System::String ^ count, ... cli::array &lt;System::Data::Objects::ObjectParameter ^&gt; ^ parameters);" />
<MemberSignature Language="F#" Value="member this.Skip : string * string * System.Data.Objects.ObjectParameter[] -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.Skip (keys, count, parameters)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="keys" Type="System.String" />
<Parameter Name="count" Type="System.String" />
<Parameter Name="parameters" Type="System.Data.Objects.ObjectParameter[]">
<Attributes>
<Attribute FrameworkAlternate="netframework-3.5">
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="keys">The key columns by which to order the results.</param>
<param name="count">The number of results to skip. This must be either a constant or a parameter reference.</param>
<param name="parameters">An optional set of query parameters that should be in scope when parsing.</param>
<summary>Orders the query results by the specified criteria and skips a specified number of results.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with both <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/order-by-entity-sql">ORDER BY</see> and [SKIP](~/docs/framework/data/adonet/ef/language-reference/skip-entity-sql.md) applied.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Data.Objects.ObjectQuery%601.Skip%2A> method cannot be used after the <xref:System.Data.Objects.ObjectQuery%601.Top%2A> method. When you use <xref:System.Data.Objects.ObjectQuery%601.Top%2A> after <xref:System.Data.Objects.ObjectQuery%601.Skip%2A>, it functions like the [LIMIT](~/docs/framework/data/adonet/ef/language-reference/limit-entity-sql.md) statement of an clause.
## Examples
This example gets five `Product` objects after skipping the first three in the query result, sorted by `Product.ListPrice`.
[!code-csharp[DP ObjectServices Concepts#Projection_SkipLimit](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#projection_skiplimit)]
[!code-vb[DP ObjectServices Concepts#Projection_SkipLimit](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#projection_skiplimit)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">Any argument is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="keys" /> is an empty string.
-or-
<paramref name="count" /> is an empty string.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator">
<MemberSignature Language="C#" Value="System.Collections.Generic.IEnumerator&lt;T&gt; IEnumerable&lt;T&gt;.GetEnumerator ();" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance class System.Collections.Generic.IEnumerator`1&lt;!T&gt; System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.System#Collections#Generic#IEnumerable&lt;T&gt;#GetEnumerator" />
<MemberSignature Language="VB.NET" Value="Function GetEnumerator () As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator" />
<MemberSignature Language="C++ CLI" Value=" virtual System::Collections::Generic::IEnumerator&lt;T&gt; ^ System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator() = System::Collections::Generic::IEnumerable&lt;T&gt;::GetEnumerator;" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.Generic.IEnumerable`1.GetEnumerator</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Collections.Generic.IEnumerator&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Returns an enumerator that iterates through the results of the query.</summary>
<returns>An <see cref="T:System.Collections.Generic.IEnumerator`1" /> object that can be used to iterate through the results.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Calling <xref:System.Data.Objects.ObjectQuery%601.System%23Collections%23Generic%23IEnumerable%7BT%7D%23GetEnumerator%2A> executes the query.
]]></format>
</remarks>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Top">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; Top (string count, params System.Data.Objects.ObjectParameter[] parameters);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; Top(string count, class System.Data.Objects.ObjectParameter[] parameters) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Top(System.String,System.Data.Objects.ObjectParameter[])" />
<MemberSignature Language="VB.NET" Value="Public Function Top (count As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ Top(System::String ^ count, ... cli::array &lt;System::Data::Objects::ObjectParameter ^&gt; ^ parameters);" />
<MemberSignature Language="F#" Value="member this.Top : string * System.Data.Objects.ObjectParameter[] -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.Top (count, parameters)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="count" Type="System.String" />
<Parameter Name="parameters" Type="System.Data.Objects.ObjectParameter[]">
<Attributes>
<Attribute FrameworkAlternate="netframework-3.5">
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="count">The number of items in the results as a string.</param>
<param name="parameters">An optional set of query parameters that should be in scope when parsing.</param>
<summary>Limits the query results to a specified number of items.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/top-entity-sql">TOP</see> applied.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Data.Objects.ObjectQuery%601.Top%2A> is nondeterministic unless the query is sorted.
When you use the <xref:System.Data.Objects.ObjectQuery%601.Top%2A> method after the <xref:System.Data.Objects.ObjectQuery%601.Skip%2A> method, it functions like the [LIMIT](~/docs/framework/data/adonet/ef/language-reference/limit-entity-sql.md) statement of an [ORDER BY](~/docs/framework/data/adonet/ef/language-reference/order-by-entity-sql.md) clause.
## Examples
These examples are based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832).
This example creates a new <xref:System.Data.Objects.ObjectQuery%601> that contains the first two results of the existing query.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Top](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_top)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Top](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_top)]
This example gets five `Product` objects after skipping the first three in the query result, sorted by `Product.ListPrice`. <xref:System.Data.Objects.ObjectQuery%601.Top%2A> is used instead of [LIMIT](~/docs/framework/data/adonet/ef/language-reference/limit-entity-sql.md) for paging.
[!code-csharp[DP ObjectServices Concepts#Projection_SkipLimit](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#projection_skiplimit)]
[!code-vb[DP ObjectServices Concepts#Projection_SkipLimit](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#projection_skiplimit)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="count" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="count" /> is an empty string.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Union">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; Union (System.Data.Objects.ObjectQuery&lt;T&gt; query);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; Union(class System.Data.Objects.ObjectQuery`1&lt;!T&gt; query) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Union(System.Data.Objects.ObjectQuery{`0})" />
<MemberSignature Language="VB.NET" Value="Public Function Union (query As ObjectQuery(Of T)) As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ Union(System::Data::Objects::ObjectQuery&lt;T&gt; ^ query);" />
<MemberSignature Language="F#" Value="member this.Union : System.Data.Objects.ObjectQuery&lt;'T&gt; -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.Union query" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="query" Type="System.Data.Objects.ObjectQuery&lt;T&gt;" />
</Parameters>
<Docs>
<param name="query">An <see cref="T:System.Data.Objects.ObjectQuery`1" /> that represents the results to add.</param>
<summary>Combines the results of the query with the results of another object query, without any duplicates.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/union-entity-sql">UNION</see> applied to add the results of the specified <paramref name="query" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Data.Objects.ObjectQuery%601.Union%2A> adds the results of the supplied `query` without any duplicates.
The supplied `query` that defines the results to add must be of the same type or of a type that can be promoted to the type of this <xref:System.Data.Objects.ObjectQuery%601>. For example, the following is valid because `DiscontinuedProducts` can be promoted to `Products`:
```
ObjectQuery<Product>.Union(ObjectQuery<DiscontinuedProduct>)
```
The following will throw an exception because `Products` cannot be promoted to `DiscontinuedProducts`.
```
ObjectQuery <DiscontinuedProduct>.Union(ObjectQuery<Product>)
```
For an <xref:System.Data.Objects.ObjectQuery%601> of type <xref:System.Data.Common.DbDataRecord>, the records in both queries must have the same number of columns, and the types in the columns of the <xref:System.Data.Common.DbDataRecord> of the passed `query` must be promotable to the types of the columns in the <xref:System.Data.Common.DbDataRecord> of the <xref:System.Data.Objects.ObjectQuery%601>.
Parameters that are defined in the supplied `query` are merged with parameters that are defined in the <xref:System.Data.Objects.ObjectQuery%601> instance. Parameters must be unique in the combined <xref:System.Data.Objects.ObjectParameterCollection>. There cannot be two parameters in the combined collection with the same name. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
The resulting query inherits the connection from the <xref:System.Data.Objects.ObjectQuery%601> instance on which <xref:System.Data.Objects.ObjectQuery%601.Union%2A> was called.
## Examples
This example is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example uses <xref:System.Data.Objects.ObjectQuery%601.Union%2A> method to creates a new <xref:System.Data.Objects.ObjectQuery%601> object.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Distinct_Union](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_distinct_union)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Distinct_Union](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_distinct_union)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="query" /> parameter is <see langword="null" />.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="UnionAll">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; UnionAll (System.Data.Objects.ObjectQuery&lt;T&gt; query);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; UnionAll(class System.Data.Objects.ObjectQuery`1&lt;!T&gt; query) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.UnionAll(System.Data.Objects.ObjectQuery{`0})" />
<MemberSignature Language="VB.NET" Value="Public Function UnionAll (query As ObjectQuery(Of T)) As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ UnionAll(System::Data::Objects::ObjectQuery&lt;T&gt; ^ query);" />
<MemberSignature Language="F#" Value="member this.UnionAll : System.Data.Objects.ObjectQuery&lt;'T&gt; -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.UnionAll query" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="query" Type="System.Data.Objects.ObjectQuery&lt;T&gt;" />
</Parameters>
<Docs>
<param name="query">An <see cref="T:System.Data.Objects.ObjectQuery`1" /> that represents the results to add.</param>
<summary>Combines the results of the query with the results of another object query, including all duplicates.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/union-entity-sql">UNION ALL</see> applied to add the results of the specified <paramref name="query" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Data.Objects.ObjectQuery%601.UnionAll%2A> adds the results of the supplied `query` including all duplicates.
The supplied `query` that defines results to add must be of the same type or of a type that can be promoted to the type of this <xref:System.Data.Objects.ObjectQuery%601>. For example, the following is valid because `DiscontinuedProducts` can be promoted to `Products`:
```
ObjectQuery<Product>.Union(ObjectQuery<DiscontinuedProduct>)
```
The following will throw an exception because `Products` cannot be promoted to `DiscontinuedProducts`.
```
ObjectQuery <DiscontinuedProduct>.Union(ObjectQuery<Product>)
```
For an <xref:System.Data.Objects.ObjectQuery%601> of type <xref:System.Data.Common.DbDataRecord>, the records in both queries must have the same number of columns, and the types in the columns of the <xref:System.Data.Common.DbDataRecord> of the passed `query` must be promotable to the types of the columns in the <xref:System.Data.Common.DbDataRecord> of the <xref:System.Data.Objects.ObjectQuery%601>.
Parameters that are defined in the supplied `query` are merged with parameters that are defined in the <xref:System.Data.Objects.ObjectQuery%601> instance. Parameters must be unique in the combined <xref:System.Data.Objects.ObjectParameterCollection>. There cannot be two parameters in the combined collection with the same name. For more information, see [Query Builder Methods](https://msdn.microsoft.com/library/05685434-05e6-41c2-8d5e-8933b88a40b0).
The resulting query inherits the connection from the <xref:System.Data.Objects.ObjectQuery%601> instance on which <xref:System.Data.Objects.ObjectQuery%601.UnionAll%2A> was called.
## Examples
The example in this topic is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example uses the <xref:System.Data.Objects.ObjectQuery%601.UnionAll%2A> method to create a new <xref:System.Data.Objects.ObjectQuery%601> object. Then it calls the <xref:System.Data.Objects.ObjectQuery%601.Distinct%2A> method on the new <xref:System.Data.Objects.ObjectQuery%601> object to get the unique results of this query.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Distinct_UnionAll](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_distinct_unionall)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Distinct_UnionAll](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_distinct_unionall)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="query" /> parameter is <see langword="null" />.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
<Member MemberName="Where">
<MemberSignature Language="C#" Value="public System.Data.Objects.ObjectQuery&lt;T&gt; Where (string predicate, params System.Data.Objects.ObjectParameter[] parameters);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Data.Objects.ObjectQuery`1&lt;!T&gt; Where(string predicate, class System.Data.Objects.ObjectParameter[] parameters) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Data.Objects.ObjectQuery`1.Where(System.String,System.Data.Objects.ObjectParameter[])" />
<MemberSignature Language="VB.NET" Value="Public Function Where (predicate As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of T)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; System::Data::Objects::ObjectQuery&lt;T&gt; ^ Where(System::String ^ predicate, ... cli::array &lt;System::Data::Objects::ObjectParameter ^&gt; ^ parameters);" />
<MemberSignature Language="F#" Value="member this.Where : string * System.Data.Objects.ObjectParameter[] -&gt; System.Data.Objects.ObjectQuery&lt;'T&gt;" Usage="objectQuery.Where (predicate, parameters)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Data.Entity</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Data.Objects.ObjectQuery&lt;T&gt;</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="predicate" Type="System.String" />
<Parameter Name="parameters" Type="System.Data.Objects.ObjectParameter[]">
<Attributes>
<Attribute FrameworkAlternate="netframework-3.5">
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="predicate">The filter predicate.</param>
<param name="parameters">Zero or more parameters that are used in this method.</param>
<summary>Limits the query to results that match specified filtering criteria.</summary>
<returns>A new <see cref="T:System.Data.Objects.ObjectQuery`1" /> instance that is equivalent to the original instance with <see href="https://docs.microsoft.com/dotnet/framework/data/adonet/ef/language-reference/where-entity-sql">WHERE</see> applied.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
This example is based on the [AdventureWorks Sales Model](https://msdn.microsoft.com/library/f16cd988-673f-4376-b034-129ca93c7832). The example creates a new <xref:System.Data.Objects.ObjectQuery%601> that contains results of the existing query filtered by the following criteria: `"it.ProductID = 900"`.
[!code-csharp[DP ObjectServices Concepts#ObjectQuery_Where](~/samples/snippets/csharp/VS_Snippets_Data/DP ObjectServices Concepts/CS/Source.cs#objectquery_where)]
[!code-vb[DP ObjectServices Concepts#ObjectQuery_Where](~/samples/snippets/visualbasic/VS_Snippets_Data/DP ObjectServices Concepts/VB/Source.vb#objectquery_where)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="predicate" /> is <see langword="null" />.
-or-
<paramref name="parameters" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="predicate" /> is an empty string.</exception>
<related type="Article" href="~/docs/framework/data/adonet/ef/querying-a-conceptual-model.md">Querying Data as Objects (Entity Framework)</related>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.