Identifier

Identifier

SharePoint 2007

In the Business Data Catalog, Entity instances should have a persistent identity, such as a primary key, so that you can search for and locate them using the key (identifier). Without an identifier, the Business Data Catalog cannot uniquely identify an entity instance. The data returned by a back-end application method is just a blob of data without identifiers. Only if the returned data also has identifiers can the data have semantic meaning in the Business Data Catalog, and only then can you have actions, search, and index on the entities.

However, it is possible to have an entity that does not need an identifier. For an example, see the Address entity in the SampleWebService metadata sample in the SDK. In this case, we want to display a list of addresses for a customer using associations, and do not require the ability to search or relate the addresses with any other entity. Addresses in this case are just a blob of data. Without an identifier, the Address entity cannot have actions on it, cannot be searched or indexed, cannot be related, and cannot be used in any of the Business Data features except the Related List Web Part.

The Business Data Catalog supports entitles with composite keys by allowing you to define multiple identifiers for an entity. When you define two or more identifiers for an entity, the Business Data Catalog simply uses the combination of the identifiers as the unique key.

Identifiers must be primitives. The following primitives are supported:

  • System.Boolean

  • System.Byte

  • System.Char

  • System.DateTime

  • System.Decimal

  • System.Double

  • System.Int32

  • System.Int64

  • System.Int16

  • System.Single

NoteNote:

GUIDs are first-class Business Data Catalog primitives. They can be used as Properties, DefaultValues, and Identifiers.

Identifiers enable the Business Data Catalog to uniquely identify an entity instance. If you define an entity without an identifier, then that entity cannot have actions on it, cannot be searched or indexed, and cannot be used in any of the Business Data features except the Related List Web Part.

If a TypeDescriptor represents an identifier of an entity in the system, you should tag it with the IdentifierName attribute in the metadata, as shown in the following code example.

<TypeDescriptor TypeName="System.Int32" IdentifierName="ProductID" Name="MinProductID">

The IdentifierName attribute on an input TypeDescriptor signals the Business Data Catalog to insert the identifier value of the entity instance of relevance before executing the method. For example, if this is part of a SpecificFinder MethodInstance, the user has probably provided the identifier value for the entity instance he or she wants to retrieve. The Business Data Catalog inserts that value into this slot after fully instantiating this parameter by using all the default values.

  • Finder   In a Finder method, tag as many TypeDescriptors in the return parameter as there are identifiers for the entity instances you want to find. This indicates for the Business Data Catalog which fields in the return parameter to use as the identifiers for the entity.

  • SpecificFinder   In a SpecificFinder method, tag the TypeDescriptors in both input and return parameters. Because SpecificFinder methods take the key (ID) as the input, you must tag the identifiers in the input parameter as well as in the return parameter.

  • Association   Tag both the source and destination identifiers in Association methods. Also, if the entity is outside of the scope of the TypeDescriptor that you are defining, also add the IdentifierEntityName attribute to qualify the identifier with its entity name.

    For example, in the Customer to Sales Order association in the AdventureWorks 2000 sample, the Customer entity defines the Association method GetSalesOrdersForCustomer. In the return parameter, the SalesOrderID property that is returned is outside the scope of the current entity (Customer) and therefore, you should tag it with the IdentifierEntityName attribute in addition to the IdentifierName attribute. This enables the Business Data Catalog to correctly insert the identifier values for the SalesOrder entity instances.

    <TypeDescriptor TypeName="System.Int32" IdentifierName="SalesOrderID" IdentifierEntityName="SalesOrder" Name="SalesOrderID">
    

You do not need to tag TypeDescriptor with the IdentifierName and IdentifierEntityName attributes in every instance of a TypeDescriptor that represents an ID field. For example, the Order and LineItem entities in the SampleWebService metadata sample, the LineItem entity has a composite key of OrderID and ProductID. In the Association method GetLineItemsForOrder defined in the LineItem entity, you do not need to tag the OrderID in the return parameter because it is only a field coming back from the Web method and you do not need to relate any other entity with it. However, you must tag the OrderID and the ProductID with the IdentifierName attributes as they are the identifiers for the local (destination) entity in the association. In the same example, you must tag the input TypeDescriptor (OrderID) with both the IdentifierName and IdentifierEntityName attributes because the OrderID is an identifier of an entity that is outside the scope of the current entity (LineItem).

<Method Name="GetLineItemsForOrder">
          <Parameters>
            <Parameter Direction="In" Name="ordid">
              <TypeDescriptor TypeName="System.String" IdentifierName="OrderID" IdentifierEntityName="Order" Name="ordid" />
            </Parameter>
            <Parameter Direction="Return" Name="LineItems">
              <TypeDescriptor TypeName="SampleWebServiceProxy.LineItem[], SampleWebService" IsCollection="true" Name="ArrayOfLineItem">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="SampleWebServiceProxy.LineItem, SampleWebService" Name="LineItem">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.String" IdentifierName="OrderID" Name="OrderID" />
                      <TypeDescriptor TypeName="System.String" IdentifierName="ProductID" Name="ProductID" />
                      <TypeDescriptor TypeName="System.String" Name="ProductName" />
                      <TypeDescriptor TypeName="System.Int32" Name="OrderQty" />
                      <TypeDescriptor TypeName="System.Decimal" Name="UnitPrice" />
                      <TypeDescriptor TypeName="System.Decimal" Name="LineTotal" />
                    </TypeDescriptors>
                  </TypeDescriptor>
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
        </Method>

The following example shows an identifier for the Product entity in the AdventureWorks database.

<Identifiers>
   <Identifier Name="ProductID" TypeName="System.Int32" /> 
</Identifiers>

Child Type Occurs Default Limits / Accepted Values Description

TypeName

System.String

1..1

  • System.Boolean

  • System.Byte

  • System.Char

  • System.DateTime

  • System.Decimal

  • System.Double

  • System.Int32

  • System.Int64

  • System.Int16

  • System.Single

  • System.Guid

Type of the identifier.

Community Additions

ADD
Show:
© 2016 Microsoft