LinqDataSourceStatusEventArgs.Result プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
データ操作の結果を表すオブジェクトを取得します。
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 プロパティで指定された型のオブジェクトが含まれます。