DbExpressionBuilder.Select<TProjection> Method (DbExpression, Func<DbExpression, TProjection>)
Creates a new DbProjectExpression that selects the specified expression over the given input set.
Assembly: EntityFramework (in EntityFramework.dll)
public static DbProjectExpression Select<TProjection>( this DbExpression source, Func<DbExpression, TProjection> projection )
Parameters
- source
-
Type:
System.Data.Entity.Core.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.Entity.Core.Common.CommandTrees.DbProjectExpressionA 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, <typeparamref name="TProjection" /> must be derived from DbExpression,or must be an anonymous type with DbExpression-derived properties. The following are examples of supported types for <typeparamref name="TProjection" /> : <code>source.Select(x => x.Property("Name"))</code> ( <typeparamref name="TProjection" /> is DbPropertyExpression ). <code>source.Select(x => new { Name = x.Property("Name") })</code> ( <typeparamref name="TProjection" /> is an anonymous type with a DbExpression-derived property).