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

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


DbExpressionBuilder.SelectMany Method

Definition

Overloads

SelectMany(DbExpression, Func<DbExpression,DbExpression>)

Creates a new DbApplyExpression that evaluates the given apply expression once for each element of a given input set, producing a collection of rows with corresponding input and apply columns. Rows for which apply evaluates to an empty set are not included. A DbProjectExpression is then created that selects the apply column from each row, producing the overall collection of apply results.

SelectMany<TSelector>(DbExpression, Func<DbExpression,DbExpression>, Func<DbExpression,DbExpression,TSelector>)

Creates a new DbApplyExpression that evaluates the given apply expression once for each element of a given input set, producing a collection of rows with corresponding input and apply columns. Rows for which apply evaluates to an empty set are not included. A DbProjectExpression is then created that selects the specified selector over each row, producing the overall collection of results.

SelectMany(DbExpression, Func<DbExpression,DbExpression>)

Creates a new DbApplyExpression that evaluates the given apply expression once for each element of a given input set, producing a collection of rows with corresponding input and apply columns. Rows for which apply evaluates to an empty set are not included. A DbProjectExpression is then created that selects the apply column from each row, producing the overall collection of apply results.

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

Parameters

source
DbExpression

A DbExpression that specifies the input set.

apply
Func<DbExpression,DbExpression>

A method that represents the logic to evaluate once for each member of the input set.

Returns

An new DbProjectExpression that selects the apply column from a new DbApplyExpression with the specified input and apply bindings and an DbExpressionKind of CrossApply.

Exceptions

source or apply is null.

-or-

The expression produced by apply is null.

source does not have a collection result type.

-or-

The expression produced by apply does not have a collection type.

Applies to

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

SelectMany<TSelector>(DbExpression, Func<DbExpression,DbExpression>, Func<DbExpression,DbExpression,TSelector>)

Creates a new DbApplyExpression that evaluates the given apply expression once for each element of a given input set, producing a collection of rows with corresponding input and apply columns. Rows for which apply evaluates to an empty set are not included. A DbProjectExpression is then created that selects the specified selector over each row, producing the overall collection of results.

C#
public static System.Data.Common.CommandTrees.DbProjectExpression SelectMany<TSelector>(this System.Data.Common.CommandTrees.DbExpression source, Func<System.Data.Common.CommandTrees.DbExpression,System.Data.Common.CommandTrees.DbExpression> apply, Func<System.Data.Common.CommandTrees.DbExpression,System.Data.Common.CommandTrees.DbExpression,TSelector> selector);

Type Parameters

TSelector

The method result type of selector.

Parameters

source
DbExpression

A DbExpression that specifies the input set.

apply
Func<DbExpression,DbExpression>

A method that represents the logic to evaluate once for each member of the input set.

selector
Func<DbExpression,DbExpression,TSelector>

A method that specifies how an element of the result set should be derived given an element of the input and apply sets. This method must produce an instance of a type that is compatible with SelectMany and can be resolved into a DbExpression. Compatibility requirements for TSelector are described in remarks.

Returns

An new DbProjectExpression that selects the result of the given selector from a new DbApplyExpression with the specified input and apply bindings and an DbExpressionKind of CrossApply.

Exceptions

source, apply or selector is null.

-or-

The expression produced by apply is null.

-or-

The result of selector is null on conversion to DbExpression.

source does not have a collection result type.

-or-

The expression produced by apply does not have a collection type. does not have a collection type.

Remarks

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

source.SelectMany(x => x.Property("RelatedCollection"), (source, apply) => apply.Property("Name"))

(TSelector is DbPropertyExpression).

source.SelectMany(x => x.Property("RelatedCollection"), (source, apply) => new { SourceName = source.Property("Name"), RelatedName = apply.Property("Name") })

(TSelector is an anonymous type with DbExpression-derived properties).

Applies to

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