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


Using Element (CSDL)

The Using element in conceptual schema definition language (CSDL) in the Entity Data Model (EDM) provides an alias that shortens the syntax for referring to types defined in a separate namespace.

The Using element contains two attributes. The external namespace is specified by the Namespace attribute. The alias for this namespace is specified by the Alias attribute.

The following example shows the syntax for the Using element. A Using element defines the SalesEntities alias for the Adventureworks.SalesModel namespace. An AssociationSet named FK_SalesOrderHeader_Address_BillToAddressID uses the alias SalesEntities specified in the Using element to refer to the Adventureworks.SalesModel. The schemas and object model dll for the Adventureworks.SalesModel must be in scope for this to work.

<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="Adventureworks"
   xmlns="https://schemas.microsoft.com/ado/2006/04/edm">
  <Using Namespace="Adventureworks.SalesModel" Alias="SalesEntities"/>

  <EntityContainer Name="AdventureWorksEntities">
    <EntitySet Name="Address" 
               EntityType="AdventureWorksModel.Address" />
    <EntitySet Name="Contact" 
               EntityType="AdventureWorksModel.Contact" />
<EntitySet Name="SalesOrderHeader" 
               EntityType="AdventureWorksModel.SalesOrderHeader" />

<AssociationSet Name="FK_SalesOrderHeader_Address_BillToAddressID" 
    Association="SalesEntities.FK_SalesOrderHeader_Address_BillToAddressID">
      <End Role="Address" EntitySet="Address" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeader" />
    </AssociationSet>
  </EntityContainer>
  <!-- Entity type definitions-->
</Schema>

See Also

Concepts

Schemas (EDM)