Condividi tramite


Authoring Step 7: Define the Order External ContentType

Applies to: SharePoint Server 2010

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

Note

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

Prerequisites

Authoring Step 6: Define the Region External ContentType

To define the Order entity

  • Add the XML for the Order entity after the Region entity element and before the Entities end tag (</Entities>). This XML defines the entity’s title, identifier, and methods to return orders.

    <Entity Namespace="SampleWebService" Version="1.2.0.0" EstimatedInstanceCount="10000" Name="WSOrder" DefaultDisplayName="WSOrder">
      <Properties>
        <Property Name="OutlookItemType" Type="System.String">Task</Property>
      </Properties>
      <Identifiers>
        <Identifier TypeName="System.String" Name="OrderID" />
      </Identifiers>
      <Methods>
        <Method IsStatic="false" Name="GetOrderByID">
          <Parameters>
            <Parameter Direction="In" Name="id">
              <TypeDescriptor TypeName="System.String" IdentifierName="OrderID" Name="id" DefaultDisplayName="OrderID" />
            </Parameter>
            <Parameter Direction="Return" Name="GetOrderByID">
              <TypeDescriptor TypeName="BCSServiceProxy.Order, http://air-mail/WSOrders2010/service.asmx?wsdl" Name="GetOrderByID">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="System.String" ReadOnly="true" IdentifierName="OrderID" Name="OrderID" />
                  <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" IdentifierEntityName="WSCustomer" IdentifierEntityNamespace="SampleWebService" ForeignIdentifierAssociationName="GetOrdersForCustomer" Name="CustomerID" />
                  <TypeDescriptor TypeName="System.String" Name="RegionID" />
                  <TypeDescriptor TypeName="System.String" Name="CurrencyCode" />
                  <TypeDescriptor TypeName="System.Decimal" Name="SubTotal">
                    <Properties>
                      <Property Name="Decimal Digits" Type="System.Int32">4</Property>
                    </Properties>
                  </TypeDescriptor>
                  <TypeDescriptor TypeName="System.String" Name="OrderDate">
                    <Properties>
                      <Property Name="OfficeProperty" Type="System.String">Subject</Property>
                    </Properties>
                  </TypeDescriptor>
                  <TypeDescriptor TypeName="System.String" Name="ShipDate" />
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <MethodInstance Type="SpecificFinder" ReturnParameterName="GetOrderByID" Default="true" Name="GetOrderByID" DefaultDisplayName="Read Item WSOrder">
              <Properties>
                <Property Name="LastDesignedOfficeItemType" Type="System.String">Task</Property>
              </Properties>
            </MethodInstance>
          </MethodInstances>
        </Method>
        <Method IsStatic="false" Name="GetOrders">
          <Parameters>
            <Parameter Direction="Return" Name="GetOrders">
              <TypeDescriptor TypeName="BCSServiceProxy.Order[], http://air-mail/WSOrders2010/service.asmx?wsdl" IsCollection="true" Name="GetOrders">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="BCSServiceProxy.Order, http://air-mail/WSOrders2010/service.asmx?wsdl" Name="GetOrdersElement">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.String" ReadOnly="true" IdentifierName="OrderID" Name="OrderID" />
                      <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" IdentifierEntityName="WSCustomer" IdentifierEntityNamespace="SampleWebService" ForeignIdentifierAssociationName="GetOrdersForCustomer" Name="CustomerID" />
                      <TypeDescriptor TypeName="System.String" Name="RegionID" />
                      <TypeDescriptor TypeName="System.String" Name="CurrencyCode" />
                      <TypeDescriptor TypeName="System.Decimal" Name="SubTotal">
                        <Properties>
                          <Property Name="Decimal Digits" Type="System.Int32">4</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="OrderDate" />
                      <TypeDescriptor TypeName="System.String" Name="ShipDate" />
                    </TypeDescriptors>
                  </TypeDescriptor>
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <MethodInstance Type="Finder" ReturnParameterName="GetOrders" Default="true" Name="GetOrders" DefaultDisplayName="WSOrder Read List">
              <Properties>
                <Property Name="UseClientCachingForSearch" Type="System.String"></Property>
                <Property Name="RootFinder" Type="System.String"></Property>
              </Properties>
            </MethodInstance>
          </MethodInstances>
        </Method>
        <Method IsStatic="false" Name="GetOrdersForCustomer">
          <Parameters>
            <Parameter Direction="In" Name="custid">
              <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" IdentifierEntityName="WSCustomer" IdentifierEntityNamespace="SampleWebService" ForeignIdentifierAssociationName="GetOrdersForCustomer" Name="custid" />
            </Parameter>
            <Parameter Direction="Return" Name="GetOrdersForCustomer">
              <TypeDescriptor TypeName="BCSServiceProxy.Order[], http://air-mail/WSOrders2010/service.asmx?wsdl" IsCollection="true" Name="GetOrdersForCustomer">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="BCSServiceProxy.Order, http://air-mail/WSOrders2010/service.asmx?wsdl" Name="GetOrdersForCustomerElement">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.String" ReadOnly="true" IdentifierName="OrderID" Name="OrderID" />
                      <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" IdentifierEntityName="WSCustomer" IdentifierEntityNamespace="SampleWebService" ForeignIdentifierAssociationName="GetOrdersForCustomer" Name="CustomerID" />
                      <TypeDescriptor TypeName="System.String" Name="RegionID" />
                      <TypeDescriptor TypeName="System.String" Name="CurrencyCode" />
                      <TypeDescriptor TypeName="System.Decimal" Name="SubTotal">
                        <Properties>
                          <Property Name="Decimal Digits" Type="System.Int32">4</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="OrderDate" />
                      <TypeDescriptor TypeName="System.String" Name="ShipDate" />
                    </TypeDescriptors>
                  </TypeDescriptor>
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <Association Name="GetOrdersForCustomer" Type="AssociationNavigator" ReturnParameterName="GetOrdersForCustomer" DefaultDisplayName="WSOrder Navigate Association">
              <Properties>
                <Property Name="ForeignFieldMappings" Type="System.String">
                  &lt;?xml version="1.0" encoding="utf-8"?&gt;
                  &lt;ForeignFieldMappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
                  &lt;ForeignFieldMappingsList&gt;
                  &lt;ForeignFieldMapping ForeignIdentifierName="CustomerID" ForeignIdentifierEntityName="WSCustomer" ForeignIdentifierEntityNamespace="SampleWebService" FieldName="CustomerID" /&gt;
                  &lt;/ForeignFieldMappingsList&gt;
                  &lt;/ForeignFieldMappings&gt;
                </Property>
              </Properties>
              <SourceEntity Namespace="SampleWebService" Name="WSCustomer" />
              <DestinationEntity Namespace="SampleWebService" Name="WSOrder" />
            </Association>
          </MethodInstances>
        </Method>
        <Method IsStatic="false" Name="GetOrdersForCustomerAndRegion">
          <Parameters>
            <Parameter Direction="In" Name="custid">
              <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" IdentifierEntityName="WSCustomer" IdentifierEntityNamespace="SampleWebService" ForeignIdentifierAssociationName="GetOrdersForCustomerAndRegion" Name="custid" />
            </Parameter>
            <Parameter Direction="In" Name="regid">
              <TypeDescriptor TypeName="System.String" IdentifierName="RegionID" IdentifierEntityName="WSRegion" IdentifierEntityNamespace="SampleWebService" ForeignIdentifierAssociationName="GetOrdersForCustomerAndRegion" Name="regtid" />
            </Parameter>
            <Parameter Direction="Return" Name="GetOrdersForCustomerAndRegion">
              <TypeDescriptor TypeName="BCSServiceProxy.Order[], http://air-mail/WSOrders2010/service.asmx?wsdl" IsCollection="true" Name="GetOrdersForCustomerAndRegion">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="BCSServiceProxy.Order, http://air-mail/WSOrders2010/service.asmx?wsdl" Name="GetOrdersForCustomerElement">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.String" ReadOnly="true" IdentifierName="OrderID" Name="OrderID" />
                      <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" IdentifierEntityName="WSCustomer" IdentifierEntityNamespace="SampleWebService" ForeignIdentifierAssociationName="GetOrdersForCustomer" Name="CustomerID" />
                      <TypeDescriptor TypeName="System.String" Name="RegionID" />
                      <TypeDescriptor TypeName="System.String" Name="CurrencyCode" />
                      <TypeDescriptor TypeName="System.Decimal" Name="SubTotal">
                        <Properties>
                          <Property Name="Decimal Digits" Type="System.Int32">4</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="OrderDate" />
                      <TypeDescriptor TypeName="System.String" Name="ShipDate" />
                    </TypeDescriptors>
                  </TypeDescriptor>
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <Association Name="GetOrdersForCustomerAndRegion" Type="AssociationNavigator" ReturnParameterName="GetOrdersForCustomerAndRegion" DefaultDisplayName="Orders for Customer and Region Navigate Association">
              <Properties>
                <Property Name="ForeignFieldMappings" Type="System.String">
                  &lt;?xml version="1.0" encoding="utf-8"?&gt;
                  &lt;ForeignFieldMappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
                  &lt;ForeignFieldMappingsList&gt;
                  &lt;ForeignFieldMapping ForeignIdentifierName="CustomerID" ForeignIdentifierEntityName="WSCustomer" ForeignIdentifierEntityNamespace="SampleWebService" FieldName="CustomerID" /&gt;
                  &lt;/ForeignFieldMappingsList&gt;
                  &lt;/ForeignFieldMappings&gt;
                </Property>
              </Properties>
              <SourceEntity Namespace="SampleWebService" Name="WSCustomer" />
              <SourceEntity Namespace="SampleWebService" Name="WSRegion" />
              <DestinationEntity Namespace="SampleWebService" Name="WSOrder" />
            </Association>
          </MethodInstances>
        </Method>
      </Methods>
      <AssociationGroups>
        <AssociationGroup Name="WSOrder-WSCustomer">
          <AssociationReference AssociationName="GetOrdersForCustomer" Reverse="false" EntityNamespace="SampleWebService" EntityName="WSOrder" />
        </AssociationGroup>
      </AssociationGroups>
    </Entity>
    

Next Steps

Authoring Step 8: Define the LineItem External ContentType