EntityDataSourceContextCreatingEventArgs.Context 屬性

定義

取得資料來源使用的 ObjectContext

public:
 property System::Data::Objects::ObjectContext ^ Context { System::Data::Objects::ObjectContext ^ get(); void set(System::Data::Objects::ObjectContext ^ value); };
public System.Data.Objects.ObjectContext Context { get; set; }
member this.Context : System.Data.Objects.ObjectContext with get, set
Public Property Context As ObjectContext

屬性值

資料來源使用的物件內容。

範例

下列範例示範如何建立 ObjectContext 物件的變數 Page ,以及其指派給 Context 物件的 屬性 EntityDataSourceContextCreatingEventArgs

public partial class _Default : System.Web.UI.Page  
    {  
        AdventureWorksModel.AdventureWorksEntities objCtx =  
            new AdventureWorksModel.AdventureWorksEntities();  

        protected void EntityDataSource2_ContextCreating(object sender,   
            EntityDataSourceContextCreatingEventArgs e)  
        {  
            e.Context = objCtx;  
        }  
    }  

備註

屬性 Context 可以指派給事件處理常式中長時間執行 ObjectContext 的屬性 ContextCreating 。 如需詳細資訊,請參閱 Object CoNtext Life-Cycle Management (EntityDataSource)

適用於