LinqDataSourceStatusEventArgs.Result プロパティ

定義

データ操作の結果を表すオブジェクトを取得します。

public:
 property System::Object ^ Result { System::Object ^ get(); };
public object Result { get; }
member this.Result : obj
Public ReadOnly Property Result As Object

プロパティ値

データ操作で得たデータが格納されたオブジェクト。

次の例は、 イベントのイベント ハンドラーを Inserted 示しています。 イベント ハンドラーで、 プロパティが の Exception 場合、 nullプロパティの オブジェクトから製品 ID が Result 取得されます。 製品 ID はテーブルの主キーであり、データベースによって設定されるため、挿入操作が完了するまで値は認識されません。 プロパティが と等しくない場合 Exception 、例外メッセージがログに null記録されます。 その後、 ExceptionHandled プロパティは に true設定されます。

protected void LinqDataSource_Inserted(object sender, LinqDataSourceStatusEventArgs e)
{
    if (e.Exception == null)
    {
        Product newProduct = (Product)e.Result;
        Literal1.Text = "The new product id is " + newProduct.ProductID;
        Literal1.Visible = true;            
    }
    else
    {
        LogError(e.Exception.Message);
        Literal1.Text = "We are sorry. There was a problem saving the record. The administrator has been notified.";
        Literal1.Visible = true;
        e.ExceptionHandled = true;            
    }
}
Protected Sub LinqDataSource_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs)
    If (IsNothing(e.Exception)) Then
        Dim newProduct As Product
        newProduct = CType(e.Result, Product)
        Literal1.Text = "The new product id is " & newProduct.ProductID
        Literal1.Visible = True
    Else
        LogError(e.Exception.Message)
        Literal1.Text = "We are sorry. There was a problem saving the record. The administrator has been notified."
        Literal1.Visible = True
        e.ExceptionHandled = True
    End If
End Sub

注釈

プロパティを Result 使用して、データ操作から返される値を調べます。 データ操作から出力パラメーターを取得したり、クエリから返される値を変更したりできます。

プロパティに Result 格納されるデータは、実行されたデータ操作の種類によって異なります。 データを削除すると、 Result プロパティには、 プロパティで TableName 指定された型のオブジェクトと、データ ソースから削除された元の値が含まれます。 データを挿入または更新すると、 Result プロパティには、 プロパティで TableName 指定された型のオブジェクトと、データ ソースに保存された新しい値が含まれます。 データを選択すると、 Result プロパティにはクエリの結果が含まれます。

選択クエリで、データのグループ化、または プロパティで指定された型のプロパティのサブセットの選択が TableName 含まれる場合、 Result プロパティには動的に作成された型のオブジェクトが含まれます。 それ以外の場合、 Result プロパティには、 プロパティで指定された型のオブジェクトが TableName 含まれます。

適用対象