Default 属性 (EntityType CSDL)

在 实体数据模型 (EDM) 中,Property 元素的 Default 属性 (Attribute) 指定了在创建该类型的实例时分配给该属性 (Property) 的值。

以下 Department 实体的定义包括 4 个 Property 元素。每个属性 (Property) 都有一个使用已分配数据类型的 Type 属性 (Attribute)。例如,GroupName 属性 (Property) 包括 Default 赋值“New Hire”。

  <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" Default="New Hire" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
  </EntityType>

另请参见

概念

Default 属性 (EntityType SSDL)