DbExpressionBuilder.Select<TProjection> Metodo

Definizione

Crea un nuovo DbProjectExpression oggetto che seleziona l'espressione specificata sul set di input specificato.

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

Parametri di tipo

TProjection

Tipo di risultato del metodo di projection.

Parametri

source
DbExpression

Espressione che specifica il set di input.

projection
Func<DbExpression,TProjection>

Metodo che specifica come derivare l'espressione proiettata in base a un membro del set di input. Questo metodo deve produrre un'istanza di un tipo compatibile con Select e può essere risolta in un oggetto DbExpression. I requisiti di compatibilità per TProjection sono descritti nelle note.

Valori restituiti

Nuovo DbProjectExpression che rappresenta l'operazione di selezione.

Eccezioni

source o projection è null.

oppure

Il risultato di projection è Null.

Commenti

Per essere compatibile con Select, TProjection deve essere derivato da DbExpressiono deve essere un tipo anonimo con proprietà derivate da DbExpression. Di seguito sono riportati esempi di tipi supportati per TProjection:

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

(TProjection è DbPropertyExpression).

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

(TProjection è un tipo anonimo con una proprietà derivata da DbExpression).

Si applica a