Прочетете на английски Редактиране

Споделяне чрез


DbExpressionBuilder.Select<TProjection> Method

Definition

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

C#
public static System.Data.Common.CommandTrees.DbProjectExpression Select<TProjection>(this System.Data.Common.CommandTrees.DbExpression source, Func<System.Data.Common.CommandTrees.DbExpression,TProjection> projection);

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

Продукт Версии
.NET Framework 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