Share via


Authoring Step 7: Define the Order entity

At its basic level, an entity consists of a title (defined in the Properties element), a unique identifier (which equates to a primary key), and methods that are used to both define the fields of an entity as well as tell the Business Data Catalog how to pull the entity data out of the LOB system.

In the case of databases, a Business Data Catalog method contains a Properties element that defines the database query, a Parameters element that defines the data returned from the query, and a MethodInstances element that defines the different ways the method can be called. However, in the case of Web services, a method describes the Web method to invoke to get the desired data. The method name should match the Web method name and the Parameters element defines the data returned from the Web method; a MethodInstances element defines the different ways the method can be called. All names and types should match the names and types in the Web services proxy.

In this step, you will define an entity named Order. The Order entity demonstrates an association that has two source entities: Customer and Region. For more information, see the following definition of GetOrdersForCustomerAndRegion. It also shows that you can define filters in association methods.

Note

The back-end Web method should support the filters you define.

Prerequisites

Authoring Step 6: Define the Region entity

To define the order entity

  • Add the XML for the Order entity after the Region entity element. This XML defines the entity’s title, identifier, and methods to return orders.

        <Entity EstimatedInstanceCount="10000" Name="Order">
          <Properties>
            <Property Name="Title" Type="System.String">OrderID</Property>
          </Properties>
          <Identifiers>
            <Identifier TypeName="System.String" Name="OrderID" />
          </Identifiers>
          <Methods>
            <!--Association method - Demonstrates an assoication that has 
            two sources - Customer and Region.-->
            <!--Also demonstrates that you can have filters in association 
            methods as well.-->
            <Method Name="GetOrdersForCustomerAndRegion">
              <FilterDescriptors>
                <FilterDescriptor Type="Comparison" Name="CurrencyCode" >
                  <Properties>
                    <Property Name="Comparator" Type="System.String">Equals</Property>
                  </Properties>
                </FilterDescriptor>
              </FilterDescriptors>
              <Parameters>
                <Parameter Direction="In" Name="custid">
                  <!--Specify the IdentifierEntityName when the identifier 
                  you want to point to is not in the local entity. -->
                  <!--In this case, the input parameters for this 
                  association are the foreign keys from the Customer and 
                  Region entities.-->
                  <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" IdentifierEntityName="Customer" Name="custid" />
                </Parameter>
                <Parameter Direction="In" Name="regid">
                  <TypeDescriptor TypeName="System.String" IdentifierName="RegionID" IdentifierEntityName="Region" Name="regid" />
                </Parameter>
                <Parameter Direction="In" Name="curcode">
                  <TypeDescriptor TypeName="System.String" AssociatedFilter="CurrencyCode" Name="curcode" />
                </Parameter>
                <Parameter Direction="Return" Name="Orders">
                  <TypeDescriptor TypeName="SampleWebServiceProxy.Order[], SampleWebService" IsCollection="true" Name="ArrayOfOrder">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="SampleWebServiceProxy.Order, SampleWebService" Name="Order">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="System.String" IdentifierName="OrderID" Name="OrderID" />
                          <TypeDescriptor TypeName="System.String" Name="CustomerID" />
                          <TypeDescriptor TypeName="System.String" Name="RegionID" />
                          <TypeDescriptor TypeName="System.String" Name="CurrencyCode" />
                          <TypeDescriptor TypeName="System.Decimal" Name="SubTotal" />
                          <TypeDescriptor TypeName="System.String" Name="OrderDate" />
                          <TypeDescriptor TypeName="System.String" Name="ShipDate" />
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
            </Method>
            <Method Name="GetOrderByID">
              <Parameters>
                <Parameter Direction="In" Name="id">
                  <TypeDescriptor TypeName="System.String" IdentifierName="OrderID" Name="id" />
                </Parameter>
                <Parameter Direction="Return" Name="Order">
                  <TypeDescriptor TypeName="SampleWebServiceProxy.Order, SampleWebService" Name="Order">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.String" IdentifierName="OrderID" Name="OrderID" />
                      <TypeDescriptor TypeName="System.String" Name="CustomerID" />
                      <TypeDescriptor TypeName="System.String" Name="RegionID" />
                      <TypeDescriptor TypeName="System.String" Name="CurrencyCode" />
                      <TypeDescriptor TypeName="System.Decimal" Name="SubTotal" />
                      <TypeDescriptor TypeName="System.String" Name="OrderDate" />
                      <TypeDescriptor TypeName="System.String" Name="ShipDate" />
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Type="SpecificFinder" ReturnParameterName="Order" ReturnTypeDescriptorName="Order" ReturnTypeDescriptorLevel="0" Name="FindOrderInstance" />
              </MethodInstances>
            </Method>
            <Method Name="GetOrders">
              <Parameters>
                <Parameter Direction="Return" Name="Orders">
                  <TypeDescriptor TypeName="SampleWebServiceProxy.Order[], SampleWebService" IsCollection="true" Name="ArrayOfOrder">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="SampleWebServiceProxy.Order, SampleWebService" Name="Order">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="System.String" IdentifierName="OrderID" Name="OrderID" />
                          <TypeDescriptor TypeName="System.String" Name="CustomerID" />
                          <TypeDescriptor TypeName="System.String" Name="RegionID" />
                          <TypeDescriptor TypeName="System.String" Name="CurrencyCode" />
                          <TypeDescriptor TypeName="System.Decimal" Name="SubTotal" />
                          <TypeDescriptor TypeName="System.String" Name="OrderDate" />
                          <TypeDescriptor TypeName="System.String" Name="ShipDate" />
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Type="Finder" ReturnParameterName="Orders" ReturnTypeDescriptorName="ArrayOfOrder" ReturnTypeDescriptorLevel="0" Name="FindOrderInstances" />
              </MethodInstances>
            </Method>
          </Methods>
        </Entity>
    

Next Steps

Authoring Step 8: Define the LineItem entity