EntityDataSource 类

定义

表示 ASP.NET 应用程序中数据绑定控件的实体数据模型(EDM)。

public ref class EntityDataSource : System::Web::UI::DataSourceControl, System::Web::DynamicData::IDynamicDataSource
public ref class EntityDataSource : System::Web::UI::DataSourceControl, System::Web::DynamicData::IDynamicDataSource, System::Web::UI::WebControls::IQueryableDataSource
[System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.EntityDataSource), "EntityDataSource.ico")]
public class EntityDataSource : System.Web.UI.DataSourceControl, System.Web.DynamicData.IDynamicDataSource
[System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.EntityDataSource), "EntityDataSource.ico")]
public class EntityDataSource : System.Web.UI.DataSourceControl, System.Web.DynamicData.IDynamicDataSource, System.Web.UI.WebControls.IQueryableDataSource
[<System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.EntityDataSource), "EntityDataSource.ico")>]
type EntityDataSource = class
    inherit DataSourceControl
    interface IDynamicDataSource
    interface IDataSource
[<System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.EntityDataSource), "EntityDataSource.ico")>]
type EntityDataSource = class
    inherit DataSourceControl
    interface IDynamicDataSource
    interface IQueryableDataSource
    interface IDataSource
[<System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.EntityDataSource), "EntityDataSource.ico")>]
type EntityDataSource = class
    inherit DataSourceControl
    interface IDynamicDataSource
    interface IDataSource
    interface IQueryableDataSource
Public Class EntityDataSource
Inherits DataSourceControl
Implements IDynamicDataSource
Public Class EntityDataSource
Inherits DataSourceControl
Implements IDynamicDataSource, IQueryableDataSource
继承
EntityDataSource
属性
实现

注解

在本主题中:

Introduction

可以将 EntityDataSource 控件与数据绑定控件一起使用,以便从 EDM 检索数据,并使用很少或没有代码在网页上显示、编辑和排序数据。 有关详细信息,请参阅 EntityDataSource Web 服务器控件概述

声明性语法

<asp:EntityDataSource
    AutoGenerateOrderByClause="True|False"
    AutoGenerateWhereClause="True|False"
    AutoPage="True|False"
    AutoSort="True|False"
    CommandText="string"
    ConnectionString="string"
    ContextType="typed ObjectContext"
    ContextTypeName="string"
    DefaultContainerName="string"
    EnableDelete="True|False"
    EnableInsert="True|False"
    EnableUpdate="True|False"
    EnableViewState="True|False"
    EntitySetName="string"
    EntityTypeFilter="string"
    GroupBy="string"
    Include="string"
    OnContextCreated="ContextCreated event handler"
    OnContextCreating="ContextCreating event handler"
    OnContextDisposing="ContextDisposing event handler"
    OnDataBinding="DataBinding event handler"
    OnDeleted="Deleted event handler"
    OnDeleting="Deleting event handler"
    OnException="IDynamicDataSource.Exception event handler"
    OnInserted="Inserted event handler"
    OnInserting="Inserting event handler"
    OnSelected="Selected event handler"
    OnSelecting="Selecting event handler"
    OnUpdated="Updated event handler"
    OnUpdating="Updating event handler"
    OrderBy="string"
    runat="server"
    Select="string"
    StoreOriginalValuesInViewState="True|False"
    Where="string"
>
        <CommandParameters />
        <DeleteParameters />
        <GroupByParameters />
        <InsertParameters />
        <OrderByParameters />
        <SelectParameters />
        <UpdateParameters />
        <WhereParameters />
</asp:EntityDataSource>

构造函数

名称 说明
EntityDataSource()

初始化 EntityDataSource 类的新实例。

EntityDataSource(EntityConnection)

使用提供的连接初始化类的新实例 EntityDataSource

属性

名称 说明
Adapter

获取控件的特定于浏览器的适配器。

(继承自 Control)
AppRelativeTemplateSourceDirectory

获取或设置包含此控件的 PageUserControl 对象的应用程序相对虚拟目录。

(继承自 Control)
AutoGenerateOrderByClause

获取或设置一个值,该值指示控件是否 EntityDataSource 根据集合中的 OrderByParameters 值动态创建 ORDER BY 子句。

AutoGenerateWhereClause

获取或设置一个值,该值指示控件是否 EntityDataSource 根据集合中 WhereParameters 定义的值动态创建 WHERE 子句。

AutoPage

获取或设置一个值,该值指示控件是否 EntityDataSource 支持在运行时浏览数据部分。

AutoSort

获取或设置一个值,该值指示控件是否 EntityDataSource 支持在运行时对数据进行排序。

BindingContainer

获取包含此控件的数据绑定的控件。

(继承自 Control)
ChildControlsCreated

获取一个值,该值指示是否已创建服务器控件的子控件。

(继承自 Control)
ClientID

获取由 ASP.NET 生成的服务器控件标识符。

(继承自 DataSourceControl)
ClientIDMode

此属性不用于数据源控件。

(继承自 DataSourceControl)
ClientIDSeparator

获取一个表示属性中使用的 ClientID 分隔符的字符值。

(继承自 Control)
CommandParameters

获取查询的参数集合。

CommandText

获取或设置定义查询的 Entity SQL 命令。

ConnectionString

获取或设置用于执行查询的连接字符串。

Context

HttpContext获取与当前 Web 请求的服务器控件关联的对象。

(继承自 Control)
ContextType

获取或设置控件使用ObjectContext的类型EntityDataSource

ContextTypeName

获取或设置控件使用的ObjectContext类型化的EntityDataSource完全限定名称。

Controls

获取一个 ControlCollection 对象,该对象代表 UI 层次结构中指定服务器控件的子控件。

(继承自 DataSourceControl)
DataItemContainer

获取对命名容器的引用(如果命名容器实现 IDataItemContainer)。

(继承自 Control)
DataKeysContainer

获取对命名容器的引用(如果命名容器实现 IDataKeysControl)。

(继承自 Control)
DefaultContainerName

获取或设置默认容器名称。

DeleteParameters

获取在删除操作期间使用的参数的集合。

DesignMode

获取一个值,该值指示控件是否在设计图面上使用。

(继承自 Control)
EnableDelete

获取或设置一个值,该值指示是否可以通过 EntityDataSource 控件删除对象。

EnableFlattening

获取或设置一个值,该值指示是否要关闭包装器创建。

EnableInsert

获取或设置一个值,该值指示是否可以通过 EntityDataSource 控件添加对象。

EnableTheming

获取一个值,该值指示此控件是否支持主题。

(继承自 DataSourceControl)
EnableUpdate

获取或设置一个值,该值指示是否可以通过 EntityDataSource 控件修改对象。

EnableViewState

获取或设置一个值,该值指示服务器控件是否将视图状态及其包含的任何子控件的视图状态保存到请求客户端。

(继承自 Control)
EntitySetName

获取或设置控件使用的 EntityDataSource 实体集的名称。

EntityTypeFilter

获取或设置将查询限制为仅特定派生类型的结果的表达式。

Events

获取控件的事件处理程序委托的列表。 此属性为只读。

(继承自 Control)
GroupBy

获取或设置指定如何对查询结果进行分组的 Entity SQL 表达式。

HasChildViewState

获取一个值,该值指示当前服务器控件的子控件是否具有保存的视图状态设置。

(继承自 Control)
ID

获取或设置分配给服务器控件的编程标识符。

(继承自 Control)
IdSeparator

获取用于分隔控件标识符的字符。

(继承自 Control)
Include

获取或设置指定要包含在查询结果中的相关对象的表达式。

InsertParameters

获取插入操作期间使用的参数的集合。

IsChildControlStateCleared

获取一个值,该值指示此控件中包含的控件是否具有控件状态。

(继承自 Control)
IsTrackingViewState

获取一个值,该值指示服务器控件是否正在保存对其视图状态的更改。

(继承自 Control)
IsViewStateEnabled

获取一个值,该值指示是否为此控件启用视图状态。

(继承自 Control)
LoadViewStateByID

获取一个值,该值指示控件是否参与加载其视图状态,而不是 ID 索引。

(继承自 Control)
NamingContainer

获取对服务器控件命名容器的引用,该容器创建唯一的命名空间,用于区分具有相同 ID 属性值的服务器控件。

(继承自 Control)
OrderBy

获取或设置指定如何对查询结果进行排序的实体 SQL 表达式。

OrderByParameters

获取用于创建 ORDER BY 子句的参数的集合。

Page

获取对 Page 包含服务器控件的实例的引用。

(继承自 Control)
Parent

获取对页面控件层次结构中服务器控件的父控件的引用。

(继承自 Control)
RenderingCompatibility

获取一个值,该值指定呈现的 HTML 将与 ASP.NET 版本兼容。

(继承自 Control)
Select

获取或设置用于定义要在查询结果中包含的属性的投影。

SelectParameters

获取用于创建投影的参数的集合。

Site

获取有关在设计图面上呈现时承载当前控件的容器的信息。

(继承自 Control)
SkinID

获取要应用于控件的 DataSourceControl 皮肤。

(继承自 DataSourceControl)
StoreOriginalValuesInViewState

获取或设置一个值,该值指示数据源中的数据是否应存储在视图状态中,以确保数据在更新或删除之前尚未由另一个进程更改。

TemplateControl

获取或设置对包含此控件的模板的引用。

(继承自 Control)
TemplateSourceDirectory

获取包含当前服务器控件的 Page 虚拟 UserControl 目录。

(继承自 Control)
UniqueID

获取服务器控件的唯一分层限定标识符。

(继承自 Control)
UpdateParameters

获取更新操作期间使用的参数的集合。

ValidateRequestMode

获取或设置一个值,该值指示控件是否检查浏览器的客户端输入是否存在潜在危险值。

(继承自 Control)
ViewState

获取状态信息的字典,该字典允许跨同一页的多个请求保存和还原服务器控件的视图状态。

(继承自 Control)
ViewStateIgnoresCase

获取一个值,该值指示对象是否 StateBag 不区分大小写。

(继承自 Control)
ViewStateMode

获取或设置此控件的视图状态模式。

(继承自 Control)
Visible

获取或设置一个值,该值指示控件是否在视觉上显示。

(继承自 DataSourceControl)
Where

获取或设置指定如何筛选查询结果的 Entity SQL 表达式。

WhereParameters

获取用于创建 WHERE 子句的参数的集合。

方法

名称 说明
AddedControl(Control, Int32)

在将子控件添加到 Controls 对象的集合 Control 后调用。

(继承自 Control)
AddParsedSubObject(Object)

通知服务器控件对元素(XML 或 HTML)进行了分析,并将该元素添加到服务器控件的对象 ControlCollection

(继承自 Control)
ApplyStyleSheetSkin(Page)

将页面样式表中定义的样式属性应用于控件。

(继承自 DataSourceControl)
BeginRenderTracing(TextWriter, Object)

开始对呈现数据进行设计时跟踪。

(继承自 Control)
BuildProfileTree(String, Boolean)

收集有关服务器控件的信息,并将其传送到 Trace 为页面启用跟踪时要显示的属性。

(继承自 Control)
ClearCachedClientID()

将缓存 ClientID 的值设置为 null

(继承自 Control)
ClearChildControlState()

删除服务器控件的子控件的控件状态信息。

(继承自 Control)
ClearChildState()

删除所有服务器控件的子控件的视图状态和控件状态信息。

(继承自 Control)
ClearChildViewState()

删除所有服务器控件的子控件的视图状态信息。

(继承自 Control)
ClearEffectiveClientIDMode()

ClientIDMode 当前控件实例的属性和任何子控件的属性设置为 Inherit

(继承自 Control)
CreateChildControls()

ASP.NET 页面框架调用,以通知使用基于组合的实现创建任何子控件的服务器控件,以准备回发或呈现。

(继承自 Control)
CreateControlCollection()

创建用于存储子控件的集合。

(继承自 DataSourceControl)
CreateView()

创建与此控件关联的新实例 EntityDataSourceView

DataBind()

将数据源绑定到调用的服务器控件及其所有子控件。

(继承自 Control)
DataBind(Boolean)

将数据源绑定到已调用的服务器控件及其所有子控件,并提供引发 DataBinding 事件的选项。

(继承自 Control)
DataBindChildren()

将数据源绑定到服务器控件的子控件。

(继承自 Control)
Dispose()

使服务器控件能够在从内存释放之前执行最终清理。

(继承自 Control)
EndRenderTracing(TextWriter, Object)

结束呈现数据的设计时跟踪。

(继承自 Control)
EnsureChildControls()

确定服务器控件是否包含子控件。 如果没有,它将创建子控件。

(继承自 Control)
EnsureID()

为未分配标识符的控件创建标识符。

(继承自 Control)
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
FindControl(String, Int32)

在当前命名容器中搜索具有指定 id 和整数的服务器控件(在参数中指定的 pathOffset 整数),这有助于搜索。 不应重写此方法的 FindControl 此版本。

(继承自 Control)
FindControl(String)

使用指定 id 参数搜索服务器控件的当前命名容器。

(继承自 DataSourceControl)
Focus()

将输入焦点设置为控件。

(继承自 DataSourceControl)
GetDesignModeState()

获取控件的设计时数据。

(继承自 Control)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetRouteUrl(Object)

获取对应于一组路由参数的 URL。

(继承自 Control)
GetRouteUrl(RouteValueDictionary)

获取对应于一组路由参数的 URL。

(继承自 Control)
GetRouteUrl(String, Object)

获取对应于一组路由参数和路由名称的 URL。

(继承自 Control)
GetRouteUrl(String, RouteValueDictionary)

获取对应于一组路由参数和路由名称的 URL。

(继承自 Control)
GetType()

获取当前实例的 Type

(继承自 Object)
GetUniqueIDRelativeTo(Control)

返回指定控件属性的前缀部分 UniqueID

(继承自 Control)
GetView(String)

获取与数据源控件关联的命名数据源视图。

GetViewNames()

获取一个名称集合,该集合表示与 EntityDataSource 控件关联的视图对象列表。

HasControls()

确定服务器控件是否包含任何子控件。

(继承自 DataSourceControl)
HasEvents()

返回一个值,该值指示是为控件或任何子控件注册事件。

(继承自 Control)
IsLiteralContent()

确定服务器控件是否仅保留文本内容。

(继承自 Control)
LoadControlState(Object)

加载控件中 EntityDataSource 需要保留的属性的状态。

LoadViewState(Object)

从方法保存 SaveViewState() 的上一页请求中还原视图状态信息。

(继承自 Control)
MapPathSecure(String)

检索虚拟路径映射到的物理路径(绝对路径或相对路径)。

(继承自 Control)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
OnBubbleEvent(Object, EventArgs)

确定服务器控件的事件是否传递页面的 UI 服务器控件层次结构。

(继承自 Control)
OnDataBinding(EventArgs)

引发 DataBinding 事件。

(继承自 Control)
OnInit(EventArgs)

LoadComplete 事件处理程序添加到 Page 包含该控件的 EntityDataSource 控件。

OnLoad(EventArgs)

引发 Load 事件。

(继承自 Control)
OnPreRender(EventArgs)

引发 PreRender 事件。

(继承自 Control)
OnUnload(EventArgs)

引发 Unload 事件。

OpenFile(String)

获取用于读取文件的一个 Stream

(继承自 Control)
RaiseBubbleEvent(Object, EventArgs)

将事件的任何源及其信息分配给控件的父级。

(继承自 Control)
RaiseDataSourceChangedEvent(EventArgs)

引发 DataSourceChanged 事件。

(继承自 DataSourceControl)
RemovedControl(Control)

Controls 对象的集合 Control 中删除子控件后调用。

(继承自 Control)
Render(HtmlTextWriter)

将服务器控件内容发送到提供的 HtmlTextWriter 对象,该对象写入要呈现在客户端上的内容。

(继承自 Control)
RenderChildren(HtmlTextWriter)

将服务器控件的子级的内容输出到所提供的 HtmlTextWriter 对象,该对象写入要呈现在客户端上的内容。

(继承自 Control)
RenderControl(HtmlTextWriter, ControlAdapter)

使用提供的对象将服务器控件内容输出到所提供的HtmlTextWriterControlAdapter对象。

(继承自 Control)
RenderControl(HtmlTextWriter)

将服务器控件内容输出到提供 HtmlTextWriter 的对象,并在启用跟踪时存储有关控件的跟踪信息。

(继承自 DataSourceControl)
ResolveAdapter()

获取负责呈现指定控件的控件适配器。

(继承自 Control)
ResolveClientUrl(String)

获取浏览器可以使用的 URL。

(继承自 Control)
ResolveUrl(String)

将 URL 转换为在请求客户端上可用 URL。

(继承自 Control)
SaveControlState()

将属性的状态保存在需要持久保存的 EntityDataSource 控件中。

SaveViewState()

保存自页面发布回服务器以来发生的任何服务器控件视图状态更改。

(继承自 Control)
SetDesignModeState(IDictionary)

设置控件的设计时数据。

(继承自 Control)
SetRenderMethodDelegate(RenderMethod)

分配事件处理程序委托以将服务器控件及其内容呈现为其父控件。

(继承自 Control)
SetTraceData(Object, Object, Object)

使用跟踪对象、跟踪数据键和跟踪数据值为呈现数据的设计时跟踪设置跟踪数据。

(继承自 Control)
SetTraceData(Object, Object)

使用跟踪数据键和跟踪数据值为呈现数据的设计时跟踪设置跟踪数据。

(继承自 Control)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)
TrackViewState()

导致跟踪服务器控件的视图状态更改,以便它们可以存储在服务器控件的对象 StateBag 中。 可通过属性访问 ViewState 此对象。

TrackViewState()

导致跟踪服务器控件的视图状态更改,以便它们可以存储在服务器控件的对象 StateBag 中。 可通过属性访问 ViewState 此对象。

(继承自 Control)

活动

名称 说明
ContextCreated

创建EntityDataSource完用于处理实体数据对象的操作时ObjectContext发生。

ContextCreating

创建用于处理实体数据对象的创建EntityDataSourceObjectContext发生。

ContextDisposing

在释放之前 ObjectContext 发生。

DataBinding

当服务器控件绑定到数据源时发生。

(继承自 Control)
Deleted

在从数据源中删除对象后发生。

Deleting

在从数据源中删除对象之前发生。

Disposed

在从内存中释放服务器控件时发生,这是请求 ASP.NET 页时服务器控件生命周期的最后阶段。

(继承自 Control)
Init

在初始化服务器控件时发生,这是其生命周期中的第一步。

(继承自 Control)
Inserted

在数据源中创建新对象后发生。

Inserting

在将新对象保存到数据源之前发生。

Load

在将服务器控件加载到对象中 Page 时发生。

(继承自 Control)
PreRender

Control 加载对象但在呈现之前发生。

(继承自 Control)
QueryCreated

EntityDataSource 创建在控件配置 EntityDataSource 期间指定的实体 SQL 查询之后发生。

Selected

执行查询后发生。

Selecting

在构造和执行查询之前发生。

Unload

从内存中卸载服务器控件时发生。

(继承自 Control)
Updated

在对对象所做的更改保存到数据源后发生。

Updating

在将对象更改保存到数据源之前发生。

显式接口实现

名称 说明
IControlBuilderAccessor.ControlBuilder

有关此成员的说明,请参阅 ControlBuilder

(继承自 Control)
IControlDesignerAccessor.GetDesignModeState()

有关此成员的说明,请参阅 GetDesignModeState()

(继承自 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

有关此成员的说明,请参阅 SetDesignModeState(IDictionary)

(继承自 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

有关此成员的说明,请参阅 SetOwnerControl(Control)

(继承自 Control)
IControlDesignerAccessor.UserData

有关此成员的说明,请参阅 UserData

(继承自 Control)
IDataBindingsAccessor.DataBindings

有关此成员的说明,请参阅 DataBindings

(继承自 Control)
IDataBindingsAccessor.HasDataBindings

有关此成员的说明,请参阅 HasDataBindings

(继承自 Control)
IDataSource.DataSourceChanged

当数据源控件以影响数据绑定控件的方式发生更改时发生。

(继承自 DataSourceControl)
IDataSource.GetView(String)

获取与DataSourceView控件关联的命名DataSourceControl对象。 某些数据源控件仅支持一个视图,而另一些控件则支持多个视图。

(继承自 DataSourceControl)
IDataSource.GetViewNames()

获取名称集合,表示与DataSourceView控件关联的对象列表DataSourceControl

(继承自 DataSourceControl)
IDynamicDataSource.Exception

在分部方法中验证失败或引发异常时发生。

IExpressionsAccessor.Expressions

有关此成员的说明,请参阅 Expressions

(继承自 Control)
IExpressionsAccessor.HasExpressions

有关此成员的说明,请参阅 HasExpressions

(继承自 Control)
IListSource.ContainsListCollection

指示数据源控件是否与一个或多个数据列表相关联。

(继承自 DataSourceControl)
IListSource.GetList()

获取可用作数据源列表的数据源控件的列表。

(继承自 DataSourceControl)
IParserAccessor.AddParsedSubObject(Object)

有关此成员的说明,请参阅 AddParsedSubObject(Object)

(继承自 Control)
IQueryableDataSource.RaiseViewChanged()

通知数据绑定控件参数对象已更改,数据绑定控件需要刷新。

扩展方法

名称 说明
ExpandDynamicWhereParameters(IDynamicDataSource)

将动态筛选器扩展到 Where 数据源可以使用的参数。

FindDataSourceControl(Control)

返回与指定控件的数据控件关联的数据源。

FindFieldTemplate(Control, String)

返回指定控件命名容器中指定列的字段模板。

FindMetaTable(Control)

返回包含数据控件的元表对象。

GetDefaultValues(IDataSource)

获取指定数据源的默认值的集合。

GetMetaTable(IDataSource)

获取指定数据源对象中表的元数据。

GetTable(IDynamicDataSource)

返回 MetaTable 与指定数据源控件关联的对象。

TryGetMetaTable(IDataSource, MetaTable)

确定表元数据是否可用。

适用于

另请参阅