ObjectQuery<T>.OfType<TResultType> Method

Definition

Limits the query to only results of a specific type.

public System.Data.Objects.ObjectQuery<TResultType> OfType<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

Produkt Versjoner
.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

See also