DbExpressionBuilder.Join Method
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() ![]() | 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. |
DbExpressionBuilder.Join Method (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 static DbJoinExpression Join( this DbExpression outer, DbExpression inner, Func<DbExpression, DbExpression> outerKey, Func<DbExpression, DbExpression> innerKey )
Parameters
- outer
-
Type:
System.Data.Entity.Core.Common.CommandTrees.DbExpression
A DbExpression that specifies the outer set argument.
- inner
-
Type:
System.Data.Entity.Core.Common.CommandTrees.DbExpression
A DbExpression that specifies the inner set argument.
- outerKey
-
Type:
System.Func<DbExpression, DbExpression>
A method that specifies how the outer key value should be derived from an element of the outer set.
- innerKey
-
Type:
System.Func<DbExpression, DbExpression>
A method that specifies how the inner key value should be derived from an element of the inner set.
Return Value
Type: System.Data.Entity.Core.Common.CommandTrees.DbJoinExpressionA 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.
Exception | Condition |
---|---|
ArgumentNullException | outer, inner, outerKey or innerKey is null. |
ArgumentException | outerKey or innerKey does not have a collection result type. |
ArgumentNullException | The expression produced by outerKey or innerKey is null. |
ArgumentException | The expression produced by outerKey or innerKey are not comparable for equality. |
DbExpressionBuilder.Join<TSelector> Method (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 static DbProjectExpression Join<TSelector>( this DbExpression outer, DbExpression inner, Func<DbExpression, DbExpression> outerKey, Func<DbExpression, DbExpression> innerKey, Func<DbExpression, DbExpression, TSelector> selector )
Parameters
- outer
-
Type:
System.Data.Entity.Core.Common.CommandTrees.DbExpression
A DbExpression that specifies the outer set argument.
- inner
-
Type:
System.Data.Entity.Core.Common.CommandTrees.DbExpression
A DbExpression that specifies the inner set argument.
- outerKey
-
Type:
System.Func<DbExpression, DbExpression>
A method that specifies how the outer key value should be derived from an element of the outer set.
- innerKey
-
Type:
System.Func<DbExpression, DbExpression>
A method that specifies how the inner key value should be derived from an element of the inner set.
- selector
-
Type:
System.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.
Return Value
Type: System.Data.Entity.Core.Common.CommandTrees.DbProjectExpressionA 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.
Type Parameters
- TSelector
The type of the selector.
Exception | Condition |
---|---|
ArgumentNullException | outer, inner, outerKey, innerKey or selector is null. |
ArgumentException | outer or inner does not have a collection result type. |
ArgumentNullException | The expression produced by outerKey or innerKey is null. |
ArgumentNullException | The result of selector is null after conversion to DbExpression. |
ArgumentException | The expressions produced by outerKey and innerKey are not compatible for equality. |
ArgumentException | The result of selector is not compatible with SelectMany. |
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: <code>outer.Join(inner, o => o.Property("ID"), i => i.Property("ID"), (o, i) => o.Property("Name"))</code> ( <typeparamref name="TSelector" /> is DbPropertyExpression ). <code>outer.Join(inner, o => o.Property("ID"), i => i.Property("ID"), (o, i) => new { OName = o.Property("Name"), IName = i.Property("Name") })</code> ( <typeparamref name="TSelector" /> is an anonymous type with DbExpression-derived properties).