Select Method

ObjectQuery<'T>.Select Method (String, ObjectParameter[])

 

Limits the query results to only the properties that are defined in the specified projection.

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

member Select : 
        projection:string *
        [<ParamArrayAttribute>] parameters:ObjectParameter[] -> ObjectQuery<DbDataRecord>

Parameters

projection
Type: System.String

The list of selected properties that defines the projection.

parameters
Type: System.Data.Objects.ObjectParameter[]

Zero or more parameters that are used in this method.

Return Value

Type: System.Data.Objects.ObjectQuery<DbDataRecord>

A new ObjectQuery<'T> instance of type DbDataRecord that is equivalent to the original instance with applied.

Exception Condition
ArgumentNullException

projection is null.

-or-

parameters is null.

ArgumentException

The projection is an empty string.

Select applies the projection specified by the projection parameter. The ObjectQuery<'T> returned by the Select method is always a row type of DbDataRecord. Use the SelectValue<'TResultType> method to return values that are simple types, entity types, or complex types. For more information, see Object Queries.

When a navigation property is included in the projection, the query results include a collection of nested DbDataRecord objects. For more information, see How to: Navigate Relationships Using Navigation Properties.

This example is based on the AdventureWorks Sales Model. The example creates a new ObjectQuery<'T> whose results are data records that contain the ProductID fields of the results of this query.

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

.NET Framework
Available since 3.5
Return to top
Show:
© 2016 Microsoft