Export (0) Print
Expand All

DbExpressionBuilder.Join<TSelector> Method (DbExpression, DbExpression, Func<DbExpression, DbExpression>, Func<DbExpression, DbExpression>, Func<DbExpression, DbExpression, TSelector>)

.NET Framework 4.5

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.

Namespace:  System.Data.Common.CommandTrees.ExpressionBuilder
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

public static DbProjectExpression Join<TSelector>(
	this DbExpression outer,
	DbExpression inner,
	Func<DbExpression, DbExpression> outerKey,
	Func<DbExpression, DbExpression> innerKey,
	Func<DbExpression, DbExpression, TSelector> selector
)

Type Parameters

TSelector

The type of the selector.

Parameters

outer
Type: System.Data.Common.CommandTrees.DbExpression

A DbExpression that specifies the outer set argument.

inner
Type: System.Data.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.Common.CommandTrees.DbProjectExpression
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.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DbExpression. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

ExceptionCondition
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 is not comparable 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:

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).

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft