LinqDataSourceValidationException.InnerExceptions プロパティ

定義

新しいデータまたは変更されたデータの検証時に発生した 1 つ以上の例外を取得します。

public:
 property System::Collections::Generic::IDictionary<System::String ^, Exception ^> ^ InnerExceptions { System::Collections::Generic::IDictionary<System::String ^, Exception ^> ^ get(); };
public System.Collections.Generic.IDictionary<string,Exception> InnerExceptions { get; }
member this.InnerExceptions : System.Collections.Generic.IDictionary<string, Exception>
Public ReadOnly Property InnerExceptions As IDictionary(Of String, Exception)

プロパティ値

例外が格納されているコレクション。

実装

次の例は、 イベントのイベント ハンドラーを Updating 示しています。 コントロールを使用して検証例外メッセージを Label 表示します。

Protected Sub LinqDataSource_Updating(ByVal sender As Object, _  
        ByVal e As LinqDataSourceUpdateEventArgs)  
    If (e.Exception IsNot Nothing) Then  
        For Each innerException As KeyValuePair(Of String, Exception) _  
                In e.Exception.InnerExceptions  
          Label1.Text &= innerException.Key & ": " & _   
                  innerException.Value.Message & "<br />"  
        Next  
        e.ExceptionHandled = True  
    End If  
End Sub  
protected void LinqDataSource_Updating(object sender,   
        LinqDataSourceUpdateEventArgs e)   
{  
    if (e.Exception != null)  
    {  
        foreach (KeyValuePair<string, Exception> innerException in   
            e.Exception.InnerExceptions)  
        {  
            Label1.Text += innerException.Key + ": " +   
                innerException.Message + "<br />";  
        }  
        e.ExceptionHandled = true;  
    }  
}  

注釈

InnerExceptionsコレクションには、更新、挿入、または削除操作の前にデータ検証中にスローされたすべての検証例外が含まれます。 値がプロパティの型と一致しない場合、検証例外が発生する可能性があります。 たとえば、数値以外の文字を使用して整数プロパティを更新しようとすると、検証例外がスローされます。 LINQ to SQL クラスには、プロパティに期待される範囲内またはパターン内の値が含まれていることを確認するカスタマイズされた検証条件を含めることもできます。

適用対象