DbExpressionBuilder.TreatAs Method (DbExpression, TypeUsage)
Creates a new DbTreatExpression.
Assembly: EntityFramework (in EntityFramework.dll)
public static DbTreatExpression TreatAs( this DbExpression argument, TypeUsage treatType )
Parameters
- argument
-
Type:
System.Data.Entity.Core.Common.CommandTrees.DbExpression
An expression that specifies the instance.
- treatType
-
Type:
System.Data.Entity.Core.Metadata.Edm.TypeUsage
Type metadata for the treat-as type.
Return Value
Type: System.Data.Entity.Core.Common.CommandTrees.DbTreatExpressionA 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.