DbExpressionBuilder.Join Method

Definition

Overloads

Join(DbExpression, DbExpression, Func<DbExpression,DbExpression>, Func<DbExpression,DbExpression>)

Creates a new DbJoinExpression that joins the sets specified by the outer and inner expressions, on an equality condition between the specified outer and inner keys, using InnerJoin as the DbExpressionKind.

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

Creates a new DbProjectExpression that projects the specified selector over the sets specified by the outer and inner expressions, joined on an equality condition between the specified outer and inner keys, using InnerJoin as the DbExpressionKind.

Join(DbExpression, DbExpression, Func<DbExpression,DbExpression>, Func<DbExpression,DbExpression>)

Creates a new DbJoinExpression that joins the sets specified by the outer and inner expressions, on an equality condition between the specified outer and inner keys, using InnerJoin as the DbExpressionKind.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Data::Common::CommandTrees::DbJoinExpression ^ Join(System::Data::Common::CommandTrees::DbExpression ^ outer, System::Data::Common::CommandTrees::DbExpression ^ inner, Func<System::Data::Common::CommandTrees::DbExpression ^, System::Data::Common::CommandTrees::DbExpression ^> ^ outerKey, Func<System::Data::Common::CommandTrees::DbExpression ^, System::Data::Common::CommandTrees::DbExpression ^> ^ innerKey);
public static System.Data.Common.CommandTrees.DbJoinExpression Join (this System.Data.Common.CommandTrees.DbExpression outer, System.Data.Common.CommandTrees.DbExpression inner, Func<System.Data.Common.CommandTrees.DbExpression,System.Data.Common.CommandTrees.DbExpression> outerKey, Func<System.Data.Common.CommandTrees.DbExpression,System.Data.Common.CommandTrees.DbExpression> innerKey);
static member Join : System.Data.Common.CommandTrees.DbExpression * 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> -> System.Data.Common.CommandTrees.DbJoinExpression
<Extension()>
Public Function Join (outer As DbExpression, inner As DbExpression, outerKey As Func(Of DbExpression, DbExpression), innerKey As Func(Of DbExpression, DbExpression)) As DbJoinExpression

Parameters

outer
DbExpression

A DbExpression that specifies the outer set argument.

inner
DbExpression

A DbExpression that specifies the inner set argument.

outerKey
Func<DbExpression,DbExpression>

A method that specifies how the outer key value should be derived from an element of the outer set.

innerKey
Func<DbExpression,DbExpression>

A method that specifies how the inner key value should be derived from an element of the inner set.

Returns

A new DbJoinExpression, with an DbExpressionKind of InnerJoin, that represents the inner join operation applied to the left and right input sets under a join condition that compares the outer and inner key values for equality.

Exceptions

outer, inner, outerKey or innerKey is null.

-or-

The expression produced by outerKey or innerKey is null.

outer or inner does not have a collection result type.

-or-

The expressions produced by outerKey and innerKey are not comparable for equality.

Applies to

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

Creates a new DbProjectExpression that projects the specified selector over the sets specified by the outer and inner expressions, joined on an equality condition between the specified outer and inner keys, using InnerJoin as the DbExpressionKind.

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

Type Parameters

TSelector

The type of the selector.

Parameters

outer
DbExpression

A DbExpression that specifies the outer set argument.

inner
DbExpression

A DbExpression that specifies the inner set argument.

outerKey
Func<DbExpression,DbExpression>

A method that specifies how the outer key value should be derived from an element of the outer set.

innerKey
Func<DbExpression,DbExpression>

A method that specifies how the inner key value should be derived from an element of the inner set.

selector
Func<DbExpression,DbExpression,TSelector>

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

Returns

A new DbProjectExpression with the specified selector as its projection, and a new DbJoinExpression as its input. The input DbJoinExpression is created with an DbExpressionKind of InnerJoin, that represents the inner join operation applied to the left and right input sets under a join condition that compares the outer and inner key values for equality.

Exceptions

outer, inner, outerKey, innerKey or selector is null.

-or-

The expression produced by outerKey or innerKey is null.

-or-

The result of selector is null after conversion to DbExpression.

outer or inner does not have a collection result type.

-or-

The expressions produced by outerKey and innerKey is not comparable for equality.

-or-

The result of selector is not compatible with SelectMany.

Remarks

To be compatible with Join, 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:

outer.Join(inner, o => o.Property("ID"), i => i.Property("ID"), (o, i) => o.Property("Name"))  

(TSelector is DbPropertyExpression).

outer.Join(inner, o => o.Property("ID"), i => i.Property("ID"), (o, i) => new { OName = o.Property("Name"), IName = i.Property("Name") })  

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

Applies to