ExpressionTypeChecker.TryAssertType 方法
判斷運算式的型別是否與提供的型別相容。
命名空間: Microsoft.Data.Edm.Validation
組件: Microsoft.Data.Edm (在 Microsoft.Data.Edm.dll 中)
語法
'宣告
<ExtensionAttribute> _
Public Shared Function TryAssertType ( _
expression As IEdmExpression, _
type As IEdmTypeReference, _
<OutAttribute> ByRef discoveredErrors As IEnumerable(Of EdmError) _
) As Boolean
'用途
Dim expression As IEdmExpression
Dim type As IEdmTypeReference
Dim discoveredErrors As IEnumerable(Of EdmError)
Dim returnValue As Boolean
returnValue = expression.TryAssertType(type, _
discoveredErrors)
public static bool TryAssertType(
this IEdmExpression expression,
IEdmTypeReference type,
out IEnumerable<EdmError> discoveredErrors
)
[ExtensionAttribute]
public:
static bool TryAssertType(
IEdmExpression^ expression,
IEdmTypeReference^ type,
[OutAttribute] IEnumerable<EdmError^>^% discoveredErrors
)
static member TryAssertType :
expression:IEdmExpression *
type:IEdmTypeReference *
discoveredErrors:IEnumerable<EdmError> byref -> bool
public static function TryAssertType(
expression : IEdmExpression,
type : IEdmTypeReference,
discoveredErrors : IEnumerable<EdmError>
) : boolean
參數
- expression
型別:Microsoft.Data.Edm.Expressions.IEdmExpression
要判斷提示其型別的運算式。
- type
型別:Microsoft.Data.Edm.IEdmTypeReference
提供的型別,要判斷提示運算式做為此型別。
- discoveredErrors
型別:System.Collections.Generic.IEnumerable<EdmError>%
如果運算式與指定之型別不相符時所產生的錯誤。
傳回值
型別:System.Boolean
如果運算式的型別與提供的型別相容,則為 true,否則為 false。
使用注意事項
在 Visual Basic 及 C# 中,您可以在任何型別 IEdmExpression 的物件上將這個方法做為執行個體方法呼叫。使用執行個體方法語法呼叫這個方法時,請省略第一個參數。如需詳細資訊,請參閱 https://msdn.microsoft.com/zh-tw/library/bb384936(v=vs.103) 或 https://msdn.microsoft.com/zh-tw/library/bb383977(v=vs.103)。
備註
如果運算式有關聯的型別,此函數將會檢查其是否符合預期的型別並停止進行其他查閱。 如果運算式宣告型別,必須驗證型別對運算式有效。 如果運算式沒有宣告型別,此方法將會嘗試以判斷提示的型別來檢查運算式本身的有效性。