EntityDataSource.ContextDisposing イベント

定義

ObjectContext が破棄される前に発生します。

public:
 event EventHandler<System::Web::UI::WebControls::EntityDataSourceContextDisposingEventArgs ^> ^ ContextDisposing;
public event EventHandler<System.Web.UI.WebControls.EntityDataSourceContextDisposingEventArgs> ContextDisposing;
member this.ContextDisposing : EventHandler<System.Web.UI.WebControls.EntityDataSourceContextDisposingEventArgs> 
Public Custom Event ContextDisposing As EventHandler(Of EntityDataSourceContextDisposingEventArgs) 

イベントの種類

今後の参照のために既存 ObjectContext のインスタンス メンバーを保持するには、次の ContextCreated コードに示すようにイベントを取り消します。

protected void EntityDataSource2_ContextDisposing(object sender,
    EntityDataSourceContextDisposingEventArgs e)
{
    e.Cancel = true;
}

注釈

コントロールによって使用される が ObjectContext 破棄されないようにするには、このイベントを EntityDataSource 処理します。 これは、ページ内の 1 つの ObjectContext インスタンスと、コントロールの複数のコントロールまたはインスタンスを使用する場合に EntityDataSource 行います。 が ObjectContext 破棄されないようにするには、 オブジェクトの プロパティを CancelEntityDataSourceContextDisposingEventArgstrue設定します。 詳細については、「 オブジェクト コンテキスト Life-Cycle管理 (EntityDataSource)」を参照してください。 オブジェクト コンテキストの詳細については、「ID 解決、状態管理、およびChange Tracking」を参照してください。

適用対象