Condividi tramite


Authoring Step 5: Define the Customer External ContentType

Applies to: SharePoint Server 2010

In this step, you define an external content type named Customer. In addition to the usual Finder and SpecificFinder methods, the Customer external content type also defines Creator, Updater, and Deleter methods to enable you to perform Create, Read, Update, and Delete (CRUD) operations in the external system.

The Web method GetCustomerByID, which is used as the SpecificFinder method, is also reused as the association method to get addresses by CustomerID. The GetCustomerByID Web method contains an address collection in the return structure that is used to get addresses for a customer by using associations. This shows that you do not always need to have a separate method as the association method. You can reuse a whole return structure or part of the return structure of another method instance (SpecificFinder in this case) as an association method.

The Customer entity also demonstrates the self-referential entity association concept. Customers can have child customers. In the BDC, this is implemented by using associations. The GetChildCustomersForCustomer Web method is used to return the child customers given a CustomerID.

The following associations are defined in the Customer external content type:

CustomerToChildCustomers (Association method GetChildCustomersForCustomer defined in the Customer external content type)

CustomerToAddress (Association method GetAddressesForCustomer defined in the Customer external content type)

Prerequisites

Authoring Step 4: Define the Address External ContentType

To define the Customer entity

  • Add the XML for the Customer entity after the Address entity element and before the Entities end tag (</Entities>).

    <Entity Namespace="SampleWebService" Version="1.0.0.0" 
            EstimatedInstanceCount="10000" Name="WSCustomer" 
            DefaultDisplayName="WSCustomer">
      <Properties>
        <Property Name="OutlookItemType" 
                  Type="System.String">Contact</Property>
      </Properties>
      <Identifiers>
        <Identifier TypeName="System.String" Name="CustomerID" />
      </Identifiers>
      <Methods>
        <Method IsStatic="false" Name="GetCustomerByID">
          <Parameters>
            <Parameter Direction="In" Name="id">
              <TypeDescriptor TypeName="System.String" 
                              IdentifierName="CustomerID" Name="id" 
                              DefaultDisplayName="CustomerID" />
            </Parameter>
            <Parameter Direction="Return" Name="GetCustomerByID">
              <TypeDescriptor 
                TypeName="BCSServiceProxy.Customer, http://air-mail/WSOrders2010/service.asmx?wsdl" 
                Name="GetCustomerByID">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="System.String" ReadOnly="true" 
                                  IdentifierName="CustomerID" Name="CustomerID" />
                  <TypeDescriptor TypeName="System.String" Name="Name">
                    <Properties>
                      <Property Name="OfficeProperty" 
                                Type="System.String">FullName</Property>
                    </Properties>
                  </TypeDescriptor>
                  <TypeDescriptor 
                    TypeName="System.Nullable`1[[System.Int64, mscorlib, 
                    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], 
                    mscorlib, Version=2.0.0.0, Culture=neutral, 
                    PublicKeyToken=b77a5c561934e089" Name="WorkPhoneNumber" />
                  <TypeDescriptor TypeName="System.Nullable`1[[System.Int64, mscorlib, 
                                  Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089]], mscorlib, 
                                  Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089" 
                                  Name="MobilePhoneNumber" />
                  <TypeDescriptor TypeName="System.String" Name="Industry" />
                  <TypeDescriptor TypeName="System.String" Name="WebSite" />
                  <TypeDescriptor TypeName="BCSServiceProxy.CustomerAddress[], 
                                  http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                  IsCollection="true" Name="CustomerAddresses">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="BCSServiceProxy.CustomerAddress, 
                                      http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                      Name="CustomerAddressesElement">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="BCSServiceProxy.CustomerStreet, 
                                          http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                          Name="Street">
                            <TypeDescriptors>
                              <TypeDescriptor TypeName="System.String" Name="BlockNumber" />
                              <TypeDescriptor TypeName="System.String" Name="Street" />
                            </TypeDescriptors>
                          </TypeDescriptor>
                          <TypeDescriptor TypeName="System.String" Name="City" />
                          <TypeDescriptor TypeName="BCSServiceProxy.States, 
                                          http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                          Name="StateProvince" />
                          <TypeDescriptor TypeName="System.String" Name="CountryRegion" />
                          <TypeDescriptor TypeName="System.String" Name="PostalCode" />
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                  <TypeDescriptor TypeName="System.String" Name="ParentCustomerID" />
                  <TypeDescriptor TypeName="System.Int32" Name="Version" />
                  <TypeDescriptor TypeName="System.DateTime" Name="ModifiedDate">
                    <Interpretation>
                      <NormalizeDateTime LobDateTimeMode="UTC" />
                    </Interpretation>
                  </TypeDescriptor>
                  <TypeDescriptor TypeName="System.Boolean" Name="IsDeleted" />
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <MethodInstance Type="SpecificFinder" ReturnParameterName="GetCustomerByID" 
                            Default="true" Name="GetCustomerByID" 
                            DefaultDisplayName="Read Item WSCustomer">
              <Properties>
                <Property Name="LastDesignedOfficeItemType" 
                          Type="System.String">Contact</Property>
              </Properties>
            </MethodInstance>
            <Association Name="CustomerToAddresses" Type="AssociationNavigator" 
                         ReturnParameterName="GetCustomerByID" 
                         ReturnTypeDescriptorPath="GetCustomerByID.CustomerAddresses"
                         DefaultDisplayName="Customer Child Customers Navigate Association">
              <SourceEntity Namespace="SampleWebService" Name="WSCustomer" />
              <DestinationEntity Namespace="SampleWebService" Name="WSAddress" />
            </Association>
          </MethodInstances>
        </Method>
        <Method IsStatic="false" Name="GetCustomers">
          <FilterDescriptors>
            <FilterDescriptor Type="Wildcard" FilterField="Name" Name="Filter">
              <Properties>
                <Property Name="UsedForDisambiguation" Type="System.Boolean">false</Property>
                <Property Name="IsDefault" Type="System.Boolean">false</Property>
                <Property Name="CaseSensitive" Type="System.Boolean">false</Property>
              </Properties>
            </FilterDescriptor>
          </FilterDescriptors>
          <Parameters>
            <Parameter Direction="In" Name="name">
              <TypeDescriptor TypeName="System.String" AssociatedFilter="Filter" Name="name" />
            </Parameter>
            <Parameter Direction="In" Name="limit">
              <TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, 
                              Version=2.0.0.0, Culture=neutral, 
                              PublicKeyToken=b77a5c561934e089]], mscorlib, 
                              Version=2.0.0.0, Culture=neutral, 
                              PublicKeyToken=b77a5c561934e089" Name="limit" />
            </Parameter>
            <Parameter Direction="Return" Name="GetCustomers">
              <TypeDescriptor TypeName="BCSServiceProxy.Customer[], 
                              http://air-mail/WSOrders2010/service.asmx?wsdl" 
                              IsCollection="true" Name="GetCustomers">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="BCSServiceProxy.Customer, 
                                  http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                  Name="GetCustomersElement">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.String" ReadOnly="true" 
                                      IdentifierName="CustomerID" Name="CustomerID" />
                      <TypeDescriptor TypeName="System.String" Name="Name">
                        <Properties>
                          <Property Name="ShowInPicker" Type="System.Boolean">true</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.Nullable`1[[System.Int64, 
                                      mscorlib, Version=2.0.0.0, Culture=neutral, 
                                      PublicKeyToken=b77a5c561934e089]], mscorlib, 
                                      Version=2.0.0.0, Culture=neutral, 
                                      PublicKeyToken=b77a5c561934e089" Name="WorkPhoneNumber" />
                      <TypeDescriptor TypeName="System.Nullable`1[[System.Int64, 
                                      mscorlib, Version=2.0.0.0, Culture=neutral, 
                                      PublicKeyToken=b77a5c561934e089]], mscorlib, 
                                      Version=2.0.0.0, Culture=neutral, 
                                      PublicKeyToken=b77a5c561934e089" Name="MobilePhoneNumber" />
                      <TypeDescriptor TypeName="System.String" Name="Industry" />
                      <TypeDescriptor TypeName="System.String" Name="WebSite" />
                      <TypeDescriptor TypeName="BCSServiceProxy.CustomerAddress[], 
                                      http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                      IsCollection="true" Name="CustomerAddresses">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="BCSServiceProxy.CustomerAddress, 
                                          http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                          Name="CustomerAddressesElement">
                            <TypeDescriptors>
                              <TypeDescriptor TypeName="BCSServiceProxy.CustomerStreet, 
                                              http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                              Name="Street">
                                <TypeDescriptors>
                                  <TypeDescriptor TypeName="System.String" Name="BlockNumber" />
                                  <TypeDescriptor TypeName="System.String" Name="Street" />
                                </TypeDescriptors>
                              </TypeDescriptor>
                              <TypeDescriptor TypeName="System.String" Name="City" />
                              <TypeDescriptor TypeName="BCSServiceProxy.States, 
                                              http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                              Name="StateProvince" />
                              <TypeDescriptor TypeName="System.String" Name="CountryRegion" />
                              <TypeDescriptor TypeName="System.String" Name="PostalCode" />
                            </TypeDescriptors>
                          </TypeDescriptor>
                        </TypeDescriptors>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="ParentCustomerID" />
                      <TypeDescriptor TypeName="System.Int32" Name="Version" />
                      <TypeDescriptor TypeName="System.DateTime" Name="ModifiedDate">
                        <Interpretation>
                          <NormalizeDateTime LobDateTimeMode="UTC" />
                        </Interpretation>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.Boolean" Name="IsDeleted" />
                    </TypeDescriptors>
                  </TypeDescriptor>
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <MethodInstance Type="Finder" ReturnParameterName="GetCustomers" Default="true" 
                            Name="GetCustomers" DefaultDisplayName="WSCustomer 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="CreateCustomer">
          <Parameters>
            <Parameter Direction="In" Name="customer">
              <TypeDescriptor TypeName="BCSServiceProxy.Customer, 
                              http://air-mail/WSOrders2010/service.asmx?wsdl" 
                              Name="customer">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="System.String" CreatorField="true" 
                                  IdentifierName="CustomerID" Name="CustomerID" />
                  <TypeDescriptor TypeName="System.String" CreatorField="true" 
                                  Name="Name" />
                  <TypeDescriptor TypeName="System.Nullable`1[[System.Int64, mscorlib, 
                                  Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089]], 
                                  mscorlib, Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089" 
                                  CreatorField="true" Name="WorkPhoneNumber" />
                  <TypeDescriptor TypeName="System.Nullable`1[[System.Int64, mscorlib, 
                                  Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089]], 
                                  mscorlib, Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089" CreatorField="true" 
                                  Name="MobilePhoneNumber" />
                  <TypeDescriptor TypeName="System.String" CreatorField="true" 
                                  Name="Industry" />
                  <TypeDescriptor TypeName="System.String" CreatorField="true" 
                                  Name="WebSite" />
                  <TypeDescriptor TypeName="BCSServiceProxy.CustomerAddress[], 
                                  http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                  IsCollection="true" CreatorField="true" 
                                  Name="CustomerAddresses">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="BCSServiceProxy.CustomerAddress, 
                                      http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                      Name="CustomerAddressesElement">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="BCSServiceProxy.CustomerStreet, 
                                          http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                          Name="Street">
                            <TypeDescriptors>
                              <TypeDescriptor TypeName="System.String" 
                                              Name="BlockNumber" />
                              <TypeDescriptor TypeName="System.String" 
                                              Name="Street" />
                            </TypeDescriptors>
                          </TypeDescriptor>
                          <TypeDescriptor TypeName="System.String" Name="City" />
                          <TypeDescriptor TypeName="BCSServiceProxy.States, 
                                          http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                          Name="StateProvince" />
                          <TypeDescriptor TypeName="System.String" Name="CountryRegion" />
                          <TypeDescriptor TypeName="System.String" Name="PostalCode" />
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                  <TypeDescriptor TypeName="System.String" CreatorField="true" 
                                  Name="ParentCustomerID" />
                  <TypeDescriptor TypeName="System.Int32" CreatorField="true" 
                                  Name="Version" />
                  <TypeDescriptor TypeName="System.DateTime" CreatorField="true" 
                                  Name="ModifiedDate">
                    <Interpretation>
                      <NormalizeDateTime LobDateTimeMode="UTC" />
                    </Interpretation>
                  </TypeDescriptor>
                  <TypeDescriptor TypeName="System.Boolean" CreatorField="true" 
                                  Name="IsDeleted" />
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
            <Parameter Direction="Return" Name="CreateCustomer">
              <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" 
                              Name="CreateCustomer" />
            </Parameter>
          </Parameters>
          <MethodInstances>
            <MethodInstance Type="Creator" ReturnParameterName="CreateCustomer" 
                            Default="true" Name="CreateCustomer" 
                            DefaultDisplayName="Create WSCustomer">
            </MethodInstance>
          </MethodInstances>
        </Method>
        <Method IsStatic="false" Name="UpdateCustomer">
          <Parameters>
            <Parameter Direction="In" Name="customer">
              <TypeDescriptor TypeName="BCSServiceProxy.Customer, 
                              http://air-mail/WSOrders2010/service.asmx?wsdl" 
                              Name="customer">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="System.String" UpdaterField="true" 
                                  IdentifierName="CustomerID" Name="CustomerID" />
                  <TypeDescriptor TypeName="System.String" UpdaterField="true" 
                                  Name="Name" />
                  <TypeDescriptor TypeName="System.Nullable`1[[System.Int64, mscorlib, 
                                  Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089]], 
                                  mscorlib, Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089" UpdaterField="true" 
                                  Name="WorkPhoneNumber" />
                  <TypeDescriptor TypeName="System.Nullable`1[[System.Int64, mscorlib, 
                                  Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089]], 
                                  mscorlib, Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089" 
                                  UpdaterField="true" Name="MobilePhoneNumber" />
                  <TypeDescriptor TypeName="System.String" UpdaterField="true" 
                                  Name="Industry" />
                  <TypeDescriptor TypeName="System.String" UpdaterField="true" 
                                  Name="WebSite" />
                  <TypeDescriptor TypeName="BCSServiceProxy.CustomerAddress[], 
                                  http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                  IsCollection="true" UpdaterField="true" 
                                  Name="CustomerAddresses">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="BCSServiceProxy.CustomerAddress, 
                                      http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                      Name="CustomerAddressesElement">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="BCSServiceProxy.CustomerStreet, 
                                          http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                          Name="Street">
                            <TypeDescriptors>
                              <TypeDescriptor TypeName="System.String" 
                                              Name="BlockNumber" />
                              <TypeDescriptor TypeName="System.String" 
                                              Name="Street" />
                            </TypeDescriptors>
                          </TypeDescriptor>
                          <TypeDescriptor TypeName="System.String" 
                                          Name="City" />
                          <TypeDescriptor TypeName="BCSServiceProxy.States, 
                                          http://air-mail/WSOrders2010/service.asmx?wsdl" 
                                          Name="StateProvince" />
                          <TypeDescriptor TypeName="System.String" 
                                          Name="CountryRegion" />
                          <TypeDescriptor TypeName="System.String" 
                                          Name="PostalCode" />
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                  <TypeDescriptor TypeName="System.String" UpdaterField="true" 
                                  Name="ParentCustomerID" />
                  <TypeDescriptor TypeName="System.Int32" UpdaterField="true" 
                                  Name="Version" />
                  <TypeDescriptor TypeName="System.DateTime" UpdaterField="true" 
                                  Name="ModifiedDate">
                    <Interpretation>
                      <NormalizeDateTime LobDateTimeMode="UTC" />
                    </Interpretation>
                  </TypeDescriptor>
                  <TypeDescriptor TypeName="System.Boolean" UpdaterField="true" 
                                  Name="IsDeleted" />
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <MethodInstance Type="Updater" Name="UpdateCustomer" 
                            DefaultDisplayName="Update WSCustomer">
            </MethodInstance>
          </MethodInstances>
        </Method>
        <Method IsStatic="false" Name="DeleteCustomer">
          <Parameters>
            <Parameter Direction="In" Name="id">
              <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" 
                              Name="id" />
            </Parameter>
          </Parameters>
          <MethodInstances>
            <MethodInstance Type="Deleter" Name="DeleteCustomer" 
                            DefaultDisplayName="Delete WSCustomer">
            </MethodInstance>
          </MethodInstances>
        </Method>
        <Method IsStatic="false" Name="GetChildCustomersForCustomer">
          <Parameters>
            <Parameter Direction="In" Name="id">
              <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" 
                              Name="id" DefaultDisplayName="CustomerID" />
            </Parameter>
            <Parameter Direction="Return" Name="Customers">
              <TypeDescriptor TypeName="BCSServiceProxy.Customer, 
                              http://air-mail/WSOrders2010/service.asmx?wsdl" 
                              Name="ArrayOfCustomers">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="System.String" ReadOnly="true" 
                                  IdentifierName="CustomerID" Name="CustomerID" />
                  <TypeDescriptor TypeName="System.String" Name="Name" />
                  <TypeDescriptor TypeName="System.Nullable`1[[System.Int64, mscorlib, 
                                  Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089]], 
                                  mscorlib, Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089" 
                                  Name="WorkPhoneNumber" />
                  <TypeDescriptor TypeName="System.Nullable`1[[System.Int64, mscorlib, 
                                  Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089]], 
                                  mscorlib, Version=2.0.0.0, Culture=neutral, 
                                  PublicKeyToken=b77a5c561934e089" 
                                  Name="MobilePhoneNumber" />
                  <TypeDescriptor TypeName="System.String" Name="Industry" />
                  <TypeDescriptor TypeName="System.String" Name="WebSite" />
                </TypeDescriptors>
              </TypeDescriptor>
            </Parameter>
          </Parameters>
          <MethodInstances>
            <Association Name="CustomerToChildCustomers" Type="AssociationNavigator" 
                         ReturnParameterName="Customers" 
                         DefaultDisplayName="Customer Child Customers Navigate Association">
              <SourceEntity Namespace="SampleWebService" Name="WSCustomer" />
              <DestinationEntity Namespace="SampleWebService" Name="WSCustomer" />
            </Association>
          </MethodInstances>
        </Method>
      </Methods>
    </Entity>
    

Next Steps

Authoring Step 6: Define the Region External ContentType