EntitySet 元素 (EntityContainer CSDL)

在 实体数据模型 (EDM) 中,概念性架构定义语言 (CSDL) 中的 EntitySet 元素指定将从概念性架构生成的类中的类型。

定义的对象模型要求可编程类和存储结构都包含在该模型上构建的应用程序的数据。映射规范语言 (MSL) 中的 EntitySetMapping 将 CSDL 中定义的 EntitySet 连接到存储架构定义语言 (SSDL) 中描述存储结构的 EntitySet

下面的 CSDL 语法演示名为 DepartmentEntitySet 的声明。此 EntitySet 是名为 HumanResourcesEntityContainer 的一部分。此 EntityContainer 是在 AdventureWorksHRModel 架构中定义的,但它是独立的元素。EntitySet 元素指定一个 Name,并标识该集指定中包含的实体的 EntityType

从此架构生成对象模型后,可以在应用程序代码中对 Department 类型的实体进行实例化。出于完整性考虑,将 EntityType 的声明放在了 EntityContainerEntitySet 的后面。

  <EntityContainer Name="HumanResources">
    <EntitySet Name="Department"
                 EntityType="AdventureWorksHRModel.Department" />

    <!-- Other EntitySet and AssociationSet tags omitted. -->
  </EntityContainer>


  <EntityType Name="Department" 
    <Key>
        <PropertyRef Name="DepartmentID">
    </Key>
    <Property Name="DepartmentID" Type="Int16" Nullable="false" />
    <Property Name="Name" Type="String" Nullable="false"  />
    <Property Name="GroupName" Type="String" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
  </EntityType>

另请参见

概念

EntitySet 元素 (EntityContainer SSDL)
EntitySetMapping 元素 (MSL)
AdventureWorks 完整模型 (EDM)