Compartilhar via


Authoring Step 8: Define the LineItem External ContentType

Applies to: SharePoint Server 2010

In this step, you will define an external content type named LineItem. The LineItem external content type 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 external content type with multiple identifiers (a composite key): OrderID and ProductID.

Prerequisites

Authoring Step 7: Define the Order External ContentType

To define the LineItem external content type

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

    <Entity Namespace="SampleWebService" Version="1.0.0.0" 
            EstimatedInstanceCount="10000" Name="WSLineItem" 
            DefaultDisplayName="WSLineItem">
      <Identifiers>
        <Identifier TypeName="System.String" Name="OrderID" />
        <Identifier TypeName="System.String" Name="ProductID" />
      </Identifiers>
      <Methods>
        <Method IsStatic="false" Name="GetLineItemByID">
          <Parameters>
            <Parameter Direction="In" Name="ordid">
              <TypeDescriptor TypeName="System.String" 
                              IdentifierName="OrderID" Name="ordid" 
                              DefaultDisplayName="OrderID" />
            </Parameter>
            <Parameter Direction="In" Name="prodid">
              <TypeDescriptor TypeName="System.String" 
                              IdentifierName="ProductID" Name="prodid" 
                              DefaultDisplayName="ProductID" />
            </Parameter>
            <Parameter Direction="Return" Name="GetLineItemByID">
              <TypeDescriptor TypeName="BCSServiceProxy.LineItem, 
                              http://air-mail/WSOrders2010/service.asmx?wsdl" 
                              Name="GetLineItemByID">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="System.String" ReadOnly="true" 
                                  IdentifierName="OrderID" Name="OrderID" />
                  <TypeDescriptor TypeName="System.String" ReadOnly="true" 
                                  IdentifierName="ProductID" Name="ProductID" />
                  <TypeDescriptor TypeName="System.String" Name="ProductName" />
                  <TypeDescriptor TypeName="System.Int32" Name="OrderQty" />
                  <TypeDescriptor TypeName="System.Decimal" Name="UnitPrice">
                    <Properties>
                      <Property Name="Decimal Digits" 
                                Type="System.Int32">4</Property>
                    </Properties>
                  </TypeDescriptor>
                  <TypeDescriptor TypeName="System.Decimal" Name="LineTotal">
                    <Properties>
                      <Property Name="Decimal Digits" 
                                Type="System.Int32">4</Property>
                    </Properties>
                  </TypeDescriptor>
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <MethodInstance Type="SpecificFinder" 
                            ReturnParameterName="GetLineItemByID" Default="true" 
                            Name="GetLineItemByID" 
                            DefaultDisplayName="Read Item WSLineItem">
              <Properties>
                <Property Name="LastDesignedOfficeItemType" 
                          Type="System.String">None</Property>
              </Properties>
            </MethodInstance>
          </MethodInstances>
        </Method>
        <Method IsStatic="false" Name="GetLineItems">
          <Parameters>
            <Parameter Direction="Return" Name="GetLineItems">
              <TypeDescriptor TypeName="BCSServiceProxy.LineItem[], 
                              http://air-mail/WSOrders2010/service.asmx?wsdl" 
                              IsCollection="true" Name="GetLineItems">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="BCSServiceProxy.LineItem, 
                                  http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                  Name="GetLineItemsElement">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.String" ReadOnly="true" 
                                      IdentifierName="OrderID" Name="OrderID" />
                      <TypeDescriptor TypeName="System.String" ReadOnly="true" 
                                      IdentifierName="ProductID" Name="ProductID" />
                      <TypeDescriptor TypeName="System.String" Name="ProductName">
                        <Properties>
                          <Property Name="ShowInPicker" 
                                    Type="System.Boolean">true</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.Int32" Name="OrderQty" />
                      <TypeDescriptor TypeName="System.Decimal" Name="UnitPrice">
                        <Properties>
                          <Property Name="Decimal Digits" 
                                    Type="System.Int32">4</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.Decimal" Name="LineTotal">
                        <Properties>
                          <Property Name="Decimal Digits" 
                                    Type="System.Int32">4</Property>
                        </Properties>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <MethodInstance Type="Finder" ReturnParameterName="GetLineItems" 
                            Default="true" Name="GetLineItems" 
                            DefaultDisplayName="WSLineItem Read List">
              <Properties>
                <Property Name="UseClientCachingForSearch" 
                          Type="System.String"></Property>
                <Property Name="RootFinder" Type="System.String"></Property>
              </Properties>
            </MethodInstance>
          </MethodInstances>
        </Method>
      </Methods>
    </Entity>