DbExpressionBuilder.TreatAs Method (DbExpression, TypeUsage)

.NET Framework (current version)
 

Creates a new DbTreatExpression.

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

public static DbTreatExpression TreatAs(
	this DbExpression argument,
	TypeUsage treatType
)

Parameters

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

An expression that specifies the instance.

treatType
Type: System.Data.Metadata.Edm.TypeUsage

Type metadata for the treat-as type.

Return Value

Type: System.Data.Common.CommandTrees.DbTreatExpression

A new DbTreatExpression with the specified argument and type.

Exception Condition
ArgumentNullException

argument or treatType is null.

ArgumentException

treatType is not in the same type hierarchy as the result type of argument.

DbTreatExpression requires that argument has a polymorphic result type, and that treatType is a type from the same type hierarchy as that result type.

.NET Framework
Available since 4.5
Return to top
Show: