Export (0) Print
Expand All

Authoring Step 8: Define the LineItem 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 LineItem. The LineItem entity demonstrates that you can have associations of type A->B->C; here, Customer and Region -> Order -> LineItem. The GetLineItemsForOrder method is the association method. Another concept we demonstrate is an entity with multiple identifiers (a composite key): OrderID and ProductID.

  • Add the XML for the LineItem entity after the Order entity element. This XML defines the entity’s title, identifiers, and methods to return LineItems.

        <!--This entity demonstrates the use of multiple 
        identifiers and associations of type A->B->C.-->
        <!--OrderID is a foriegn key from Order.-->
        <Entity EstimatedInstanceCount="10000" Name="LineItem">
          <Properties>
            <Property Name="Title" Type="System.String">ProductName</Property>
          </Properties>
          <Identifiers>
            <Identifier TypeName="System.String" Name="OrderID" />
            <Identifier TypeName ="System.String" Name="ProductID" />
          </Identifiers>
          <Methods>
            <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>
            <Method Name="GetLineItemByID">
              <Parameters>
                <Parameter Direction="In" Name="ordid">
                  <TypeDescriptor TypeName="System.String" IdentifierName="OrderID" Name="ordid" />
                </Parameter>
                <Parameter Direction="In" Name="prodid">
                  <TypeDescriptor TypeName="System.String" IdentifierName="ProductID" Name="prodid" />
                </Parameter>
                <Parameter Direction="Return" Name="LineItem">
                  <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>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Type="SpecificFinder" ReturnParameterName="LineItem" ReturnTypeDescriptorName="LineItem" ReturnTypeDescriptorLevel="0" Name="FindLineItemInstance" />
              </MethodInstances>
            </Method>
            <Method Name="GetLineItems">
              <Parameters>
                <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>
              <MethodInstances>
                <MethodInstance Type="Finder" ReturnParameterName="LineItems" ReturnTypeDescriptorName="ArrayOfLineItem" ReturnTypeDescriptorLevel="0" Name="FindLineItemInstances" />
              </MethodInstances>
            </Method>
          </Methods>
        </Entity>
    

Community Additions

ADD
Show:
© 2015 Microsoft