DbExpressionBuilder.CastTo Method (DbExpression, TypeUsage)

 

Creates a new DbCastExpression that applies a cast operation to a polymorphic argument.

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

public static DbCastExpression CastTo(
	this DbExpression argument,
	TypeUsage toType
)

Parameters

argument
Type: System.Data.Entity.Core.Common.CommandTrees.DbExpression

The argument to which the cast should be applied.

toType
Type: System.Data.Entity.Core.Metadata.Edm.TypeUsage

Type metadata that specifies the type to cast to.

Return Value

Type: System.Data.Entity.Core.Common.CommandTrees.DbCastExpression

A new DbCastExpression with the specified argument and target type.

Exception Condition
ArgumentNullException

argument or toType is null.

ArgumentException

The specified cast is not valid.