DbExpressionBuilder.Select<TProjection> Method (DbExpression, Func<DbExpression, TProjection>)

.NET Framework (current version)
 

Creates a new DbProjectExpression that selects the specified expression over the given input set.

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

public static DbProjectExpression Select<TProjection>(
	this DbExpression source,
	Func<DbExpression, TProjection> projection
)

Parameters

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

An expression that specifies the input set.

projection
Type: System.Func<DbExpression, TProjection>

A method that specifies how to derive the projected expression given a member of the input set. This method must produce an instance of a type that is compatible with Select and can be resolved into a DbExpression. Compatibility requirements for TProjection are described in remarks.

Return Value

Type: System.Data.Common.CommandTrees.DbProjectExpression

A new DbProjectExpression that represents the select operation.

Type Parameters

TProjection

The method result type of projection.

Exception Condition
ArgumentNullException

source or projection is null.

ArgumentNullException

The result of projection is null.

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

source.Select(x => x.Property("Name"))

TProjection is DbPropertyExpression).

source.Select(x => new { Name = x.Property("Name") })

(TProjection is an anonymous type with a DbExpression-derived property).

.NET Framework
Available since 4.5
Return to top
Show: