Επεξεργασία

Κοινή χρήση μέσω


DbExpressionBuilder.Select<TProjection> Method

Definition

Creates a new DbProjectExpression that selects the specified expression over the given input set.

public:
generic <typename TProjection>
[System::Runtime::CompilerServices::Extension]
 static System::Data::Common::CommandTrees::DbProjectExpression ^ Select(System::Data::Common::CommandTrees::DbExpression ^ source, Func<System::Data::Common::CommandTrees::DbExpression ^, TProjection> ^ projection);
public static System.Data.Common.CommandTrees.DbProjectExpression Select<TProjection> (this System.Data.Common.CommandTrees.DbExpression source, Func<System.Data.Common.CommandTrees.DbExpression,TProjection> projection);
static member Select : System.Data.Common.CommandTrees.DbExpression * Func<System.Data.Common.CommandTrees.DbExpression, 'Projection> -> System.Data.Common.CommandTrees.DbProjectExpression
<Extension()>
Public Function Select(Of TProjection) (source As DbExpression, projection As Func(Of DbExpression, TProjection)) As DbProjectExpression

Type Parameters

TProjection

The method result type of projection.

Parameters

source
DbExpression

An expression that specifies the input set.

projection
Func<DbExpression,TProjection>

A method that specifies how to derive the projected expression given a member of the input set. This method must produce an instance of a type that is compatible with Select and can be resolved into a DbExpression. Compatibility requirements for TProjection are described in remarks.

Returns

A new DbProjectExpression that represents the select operation.

Exceptions

source or projection is null.

-or-

The result of projection is null.

Remarks

To be compatible with Select, TProjection must be derived from DbExpression, or must be an anonymous type with DbExpression-derived properties. The following are examples of supported types for TProjection:

source.Select(x => x.Property("Name"))  

TProjection is DbPropertyExpression).

source.Select(x => new { Name = x.Property("Name") })  

(TProjection is an anonymous type with a DbExpression-derived property).

Applies to