Edit

Share via


ObjectQuery<T>.OfType<TResultType> Method

Definition

Limits the query to only results of a specific type.

public:
generic <typename TResultType>
 System::Data::Objects::ObjectQuery<TResultType> ^ OfType();
public System.Data.Objects.ObjectQuery<TResultType> OfType<TResultType> ();
member this.OfType : unit -> System.Data.Objects.ObjectQuery<'ResultType>
Public Function OfType(Of TResultType) () As ObjectQuery(Of TResultType)

Type Parameters

TResultType

The type of the ObjectResult<T> returned when the query is executed with the applied filter.

Returns

ObjectQuery<TResultType>

A new ObjectQuery<T> instance that is equivalent to the original instance with OFTYPE applied.

Exceptions

The type specified is not valid.

Remarks

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.

The OfType method can only be applied to an ObjectQuery<T> of an entity type or complex type that is defined in the EDM.

Applies to

See also