Поделиться через


Property Element (EntityType SSDL)

In the Entity Data Model (EDM), properties are the elements of EntityType declarations that contain most of the information that is used by applications. A Property element includes Type, and may include the Nullability constraint and/or the Default attribute.

The properties of the following Employee declaration contain information that is assigned after the Employee entity is created by application code. Properties that include the constraint Nullable="false" on the Type attribute must be assigned a value or the entity will throw an exception when it is saved to storage. The Nullable constraint is optional on most properties and defaults to true. The Key attribute must include the Nullable="false" assignment.

  <EntityType Name="Employee">
    <Key>
        <PropertyRef Name="EmployeeID">
    </Key>
    <Property Name="EmployeeID" Type="Int32" Nullable="false" />
    <Property Name="NationalIDNumber" Type="String" Nullable="false" />
    <Property Name="ContactID" Type="Int32" Nullable="false" />
    <Property Name="LoginID" Type="String" Nullable="false" />
    <Property Name="Title" Type="String" Nullable="false"
 Default="NewHire" />
    <Property Name="BirthDate" Type="DateTime" Nullable="false" />
    <Property Name="MaritalStatus" Type="String" Nullable="false" />
    <Property Name="Gender" Type="String" Nullable="false" />
    <Property Name="HireDate" Type="DateTime" Nullable="false" />
    <Property Name="SalariedFlag" Type="Boolean" Nullable="false" />
    <Property Name="VacationHours" Type="Int16" Nullable="false" />
    <Property Name="SickLeaveHours" Type="Int16" Nullable="false" />
    <Property Name="CurrentFlag" Type="Boolean" Nullable="false" />
    <Property Name="rowguid" Type="Guid" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
  </EntityType>

See Also

Concepts

Property Element (EntityType SSDL)