Share via


ExpressionTypeChecker.TryCast Method

Definition

Overloads

TryCast(IEdmExpression, IEdmTypeReference, IEnumerable<EdmError>)

Determines if the type of an expression is compatible with the provided type

TryCast(IEdmExpression, IEdmTypeReference, IEdmType, Boolean, IEnumerable<EdmError>)

Determines if the type of an expression is compatible with the provided type

TryCast(IEdmExpression, IEdmTypeReference, IEnumerable<EdmError>)

Determines if the type of an expression is compatible with the provided type

public static bool TryCast (this Microsoft.OData.Edm.IEdmExpression expression, Microsoft.OData.Edm.IEdmTypeReference type, out System.Collections.Generic.IEnumerable<Microsoft.OData.Edm.Validation.EdmError> discoveredErrors);
static member TryCast : Microsoft.OData.Edm.IEdmExpression * Microsoft.OData.Edm.IEdmTypeReference * seq -> bool
<Extension()>
Public Function TryCast (expression As IEdmExpression, type As IEdmTypeReference, ByRef discoveredErrors As IEnumerable(Of EdmError)) As Boolean

Parameters

expression
IEdmExpression

The expression to assert the type of.

type
IEdmTypeReference

The type to assert the expression as.

discoveredErrors
IEnumerable<EdmError>

Errors produced if the expression does not match the specified type.

Returns

A value indicating whether the expression is valid for the given type or not.

Remarks

If the expression has an associated type, this function will check that it matches the expected type and stop looking further. If an expression claims a type, it must be validated that the type is valid for the expression. If the expression does not claim a type this method will attempt to check the validity of the expression itself with the asserted type.

Applies to

TryCast(IEdmExpression, IEdmTypeReference, IEdmType, Boolean, IEnumerable<EdmError>)

Determines if the type of an expression is compatible with the provided type

public static bool TryCast (this Microsoft.OData.Edm.IEdmExpression expression, Microsoft.OData.Edm.IEdmTypeReference type, Microsoft.OData.Edm.IEdmType context, bool matchExactly, out System.Collections.Generic.IEnumerable<Microsoft.OData.Edm.Validation.EdmError> discoveredErrors);
static member TryCast : Microsoft.OData.Edm.IEdmExpression * Microsoft.OData.Edm.IEdmTypeReference * Microsoft.OData.Edm.IEdmType * bool * seq -> bool
<Extension()>
Public Function TryCast (expression As IEdmExpression, type As IEdmTypeReference, context As IEdmType, matchExactly As Boolean, ByRef discoveredErrors As IEnumerable(Of EdmError)) As Boolean

Parameters

expression
IEdmExpression

The expression to assert the type of.

type
IEdmTypeReference

The type to assert the expression as.

context
IEdmType

The context paths are to be evaluated in.

matchExactly
Boolean

A value indicating whether the expression must match the asserted type exactly, or simply be compatible.

discoveredErrors
IEnumerable<EdmError>

Errors produced if the expression does not match the specified type.

Returns

A value indicating whether the expression is valid for the given type or not.

Remarks

If the expression has an associated type, this function will check that it matches the expected type and stop looking further. If an expression claims a type, it must be validated that the type is valid for the expression. If the expression does not claim a type this method will attempt to check the validity of the expression itself with the asserted type.

Applies to