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.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Data::Common::CommandTrees::DbProjectExpression ^ SelectMany(System::Data::Common::CommandTrees::DbExpression ^ source, Func<System::Data::Common::CommandTrees::DbExpression ^, System::Data::Common::CommandTrees::DbExpression ^> ^ apply);
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);
static member SelectMany : System.Data.Common.CommandTrees.DbExpression * Func<System.Data.Common.CommandTrees.DbExpression, System.Data.Common.CommandTrees.DbExpression> -> System.Data.Common.CommandTrees.DbProjectExpression
<Extension()>
Public Function SelectMany (source As DbExpression, apply As Func(Of DbExpression, DbExpression)) As DbProjectExpression

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

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.

public:
generic <typename TSelector>
[System::Runtime::CompilerServices::Extension]
 static System::Data::Common::CommandTrees::DbProjectExpression ^ SelectMany(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);
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);
static member SelectMany : System.Data.Common.CommandTrees.DbExpression * Func<System.Data.Common.CommandTrees.DbExpression, System.Data.Common.CommandTrees.DbExpression> * Func<System.Data.Common.CommandTrees.DbExpression, System.Data.Common.CommandTrees.DbExpression, 'Selector> -> System.Data.Common.CommandTrees.DbProjectExpression
<Extension()>
Public Function SelectMany(Of TSelector) (source As DbExpression, apply As Func(Of DbExpression, DbExpression), selector As Func(Of DbExpression, DbExpression, TSelector)) As DbProjectExpression

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