Export (0) Print
Expand All
Expand Minimize

DbExpressionBuilder.Select<TProjection> Method

.NET Framework 4.5

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

Type Parameters


The method result type of projection.


Type: System.Data.Common.CommandTrees.DbExpression

An expression that specifies the input set.

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.

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


source or projection is null.


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

Supported in: 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.

© 2014 Microsoft