Compartir a través de


Condition Element (MappingFragment)

The Condition element in a MappingFragment specifies a logical requirement for the validity of the EntityType being mapped in the Entity Data Model (EDM). Mapping an EntityType identifies the columns in data tables to which properties of the related entities correspond. In the table-per-type inheritance scenario, one column of the data table is the discriminator column that indicates the derived type of an instance of an EntityType.

In the following example, the condition requires Value="1" for the PersonCategory column in order for an instance of the Person base type to be an instance of the derived type Student.

  <cs:EntityTypeMapping TypeName="SchoolDataLibTPH.Student">
    <cs:MappingFragment StoreEntitySet="Person">
      <cs:ScalarProperty Name="PersonID" ColumnName="PersonID" />
      <cs:ScalarProperty Name="FirstName" ColumnName="FirstName" />
      <cs:ScalarProperty Name="LastName" ColumnName="LastName" />
      <cs:ScalarProperty Name="EnrollmentDate" ColumnName="EnrollmentDate" />
      <cs:Condition ColumnName="PersonCategory" Value="1" />
    </cs:MappingFragment>
  </cs:EntityTypeMapping>

See Also

Tasks

How to: Define a Model with Table-per-Hierarchy Inheritance (Entity Framework)

Concepts

Condition Element (AssociationSetMapping)