EntityDataSource.ContextCreated 事件
定义
在 EntityDataSource 创建完用于处理实体数据对象的 ObjectContext 之后发生。Occurs when the EntityDataSource has finished creating the ObjectContext that is used to work with entity data objects.
public:
event EventHandler<System::Web::UI::WebControls::EntityDataSourceContextCreatedEventArgs ^> ^ ContextCreated;
public event EventHandler<System.Web.UI.WebControls.EntityDataSourceContextCreatedEventArgs> ContextCreated;
member this.ContextCreated : EventHandler<System.Web.UI.WebControls.EntityDataSourceContextCreatedEventArgs>
Public Custom Event ContextCreated As EventHandler(Of EntityDataSourceContextCreatedEventArgs)
事件类型
注解
处理此事件,以访问 ObjectContext EntityDataSource 控件用于执行查询和跟踪更改的。Handle this event to access the ObjectContext that is used by the EntityDataSource control to execute the query and track changes. 可以存储此上下文对象并将其用于之外的后续操作 EntityDataSource 。This context object can be stored and used for successive operations outside the EntityDataSource. ObjectContext从事件返回的获取 EntityDataSourceContextCreatedEventArgs ContextCreated 。The ObjectContext is obtained from the EntityDataSourceContextCreatedEventArgs that is returned by the ContextCreated event. 有关详细信息,请参阅 对象上下文 Life-Cycle 管理 (EntityDataSource) 。For more information, see Object Context Life-Cycle Management (EntityDataSource). 有关对象上下文的详细信息,请参阅 标识解析、状态管理和更改跟踪。For more information about the object context, see Identity Resolution, State Management, and Change Tracking.
ContextCreated事件允许你将已创建的分配给一个变量,以便在 ObjectContext 外进行后续操作 EntityDataSource 。The ContextCreated event allows you to assign the ObjectContext that has been created to a variable for successive operations outside the EntityDataSource. EntityDataSourceContextCreatedEventArgs.Context属性包含已在事件中创建的上下文 ContextCreating 。The EntityDataSourceContextCreatedEventArgs.Context property contains the context that has been created in the ContextCreating event. 如果用户未在事件期间分配上下文,则 ContextCreating 中包含的上下文实例 EntityDataSourceContextCreatedEventArgs.Context 是 EntityDataSource 基于 EntityDataSource.ContextTypeName 、 EntityDataSource.DefaultContainerName 或属性创建的实例 EntityDataSource.ConnectionString 。If the user does not assign a context during the ContextCreating event, the context instance contained in EntityDataSourceContextCreatedEventArgs.Context is the one created by the EntityDataSource based on the EntityDataSource.ContextTypeName, EntityDataSource.DefaultContainerName, or EntityDataSource.ConnectionString properties.