Partager via


Attributs d'annotation

Les attributs d'annotation en SSDL (Store Schema Definition Language) sont des attributs XML personnalisés dans le modèle de stockage qui fournissent des métadonnées supplémentaires concernant les éléments dans le modèle de stockage.En plus d'avoir une structure XML valide, les contraintes suivantes s'appliquent aux attributs d'annotation :

  • Les attributs d'annotation ne doivent pas figurer dans un espace de noms XML réservé pour le langage SSDL.

  • Les noms qualifiés complets de deux attributs d'annotation ne doivent pas être identiques.

Plusieurs attributs d'annotation peuvent être appliqués à un élément SSDL donné.Il est possible d'accéder aux métadonnées incluses dans des éléments d'annotation au moment de l'exécution en utilisant des classes dans l'espace de noms System.Data.Metadata.Edm.

Exemple

L'exemple ci-dessous illustre un élément EntityType avec un attribut d'annotation appliqué à la propriété OrderId.L'exemple montre également un élément d'annotation ajouté à l'élément EntityType.

<EntityType Name="Orders" xmlns:c="http://CustomNamespace">
  <Key>
    <PropertyRef Name="OrderId" />
  </Key>
  <Property Name="OrderId" Type="int" Nullable="false" 
            c:CustomAttribute="someValue"/>
  <Property Name="ProductId" Type="int" Nullable="false" />
  <Property Name="Quantity" Type="int" Nullable="false" />
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <c:CustomElement>
    Custom data here.
  </c:CustomElement>
</EntityType>
<EntityType Name="Orders" xmlns:c="http://CustomNamespace">
  <Key>
    <PropertyRef Name="OrderId" />
  </Key>
  <Property Name="OrderId" Type="int" Nullable="false" c:CustomAttribute="someValue" />
  <Property Name="ProductId" Type="int" Nullable="false" />
  <Property Name="Quantity" Type="int" Nullable="false" />
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <c:CustomElement>
          Custom data here.
        </c:CustomElement>
</EntityType>

<EntityType Name="Orders" xmlns:c="http://CustomNamespace">
  <Key>
    <PropertyRef Name="OrderId" />
  </Key>
  <Property Name="OrderId" Type="int" Nullable="false" c:CustomAttribute="someValue" />
  <Property Name="ProductId" Type="int" Nullable="false" />
  <Property Name="Quantity" Type="int" Nullable="false" />
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <c:CustomElement>
          Custom data here.
        </c:CustomElement>
</EntityType>

Voir aussi

Concepts

Éléments d'annotation (SSDL)

Spécification SSDL

Autres ressources

Spécifications CSDL, SSDL et MSL