Share via


Sample BDC Model

Applies to: SharePoint Server 2010

The following example BDC model represents a Customer external content type for an external system of type Web Service. The example, which uses the sample AdventureWorks Web service that is included with the SharePoint 2010 SDK, shows the following:

  • Adding a simple external content type WSCustomer with one Method object

  • Adding a MethodInstance object to make the Method executable at run time

  • Associating two external content types, Customer and Order

Example: Adding a Simple Entity with One Method Object

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://schemas.microsoft.com/windows/2007/BusinessDataCatalog BDCMetadata.xsd" Name="AdventureWorksWSModel" IsCached="false" xmlns="https://schemas.microsoft.com/windows/2007/BusinessDataCatalog">
   <LobSystems>
    <LobSystem Type="Wcf" Name="AdventureWorksWS">
      <Properties>
        <Property Name="WsdlFetchAuthenticationMode" Type="System.String">PassThrough</Property>
        <Property Name="WcfMexDiscoMode" Type="System.String">Disco</Property>
        <Property Name="WcfMexDocumentUrl" Type="System.String">http://webserver:90/webservice.asmx?wsdl</Property>
        <Property Name="WcfProxyNamespace" Type="System.String">BCSServiceProxy</Property>
        <Property Name="WildcardCharacter" Type="System.String">*</Property>
      </Properties>
      <LobSystemInstances>
        <LobSystemInstance Name="AdventureWorksWS">
          <Properties>
            <Property Name="WcfAuthenticationMode" Type="System.String">PassThrough</Property>
            <Property Name="WcfEndpointAddress" Type="System.String">http://webserver:90/webservice.asmx</Property>
            <Property Name="ShowInSearchUI" Type="System.String"></Property>
          </Properties>
        </LobSystemInstance>
      </LobSystemInstances>
      <Entities>
        <Entity Namespace="AdventureWorks” 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.Int32" Name="CustomerId" />
          </Identifiers>
          <Methods>
            <Method IsStatic="false" Name="GetCustomerById">
              <Parameters>
                <Parameter Direction="In" Name="customerId">
                  <TypeDescriptor TypeName="System.Int32" IdentifierName="CustomerId" Name="customerId" />
                </Parameter>
                <Parameter Direction="Return" Name="GetCustomerById">
                  <TypeDescriptor TypeName="BCSServiceProxy.SalesCustomer, AdventureWorksWS" Name="GetCustomerById">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.Int32" ReadOnly="true" IdentifierName="CustomerId" Name="CustomerId" />
                      <TypeDescriptor TypeName="System.String" Name="Title" />
                      <TypeDescriptor TypeName="System.String" Name="FirstName">
                        <Properties>
                          <Property Name="OfficeProperty" Type="System.String">FirstName</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="MiddleName" />
                      <TypeDescriptor TypeName="System.String" Name="LastName">
                        <Properties>
                          <Property Name="OfficeProperty" Type="System.String">LastName</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="EmailAddress" />
                      <TypeDescriptor TypeName="System.String" Name="Phone" />
                      <TypeDescriptor TypeName="System.DateTime" Name="ModifiedDate" />
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <!- See below>
              </MethodInstances>
            </Method>
          </Methods>
        </Entity>
      </Entities>
    </LobSystem>
  </LobSystems>
</Model>

Example: Adding a MethodInstance to Make the Method Object Executable at Run Time

In the previous example, Method is not executable at run time. The following code example shows how you can add a MethodInstance to the previous Customer entity to make Method executable.

<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>
</MethodInstances>

Associating Two entities, Customer and Order

Association is a type of MethodInstance. The following code example shows how to associate two entities. It assumes that there is another entity type named Order with a method that returns a parameter named 'Orders already defined in the model. Here, the model associates the two entities Customer and Order.

<!—BDC has three types of association operations - AssociationNavigator, Associate and DisAssociate -->
<MethodInstances>
   <Association Name="GetOrdersByCustomer" Type="AssociationNavigator" ReturnParameterName="Orders">
<!—Name of the Source entity in the association -->
      <Source Name="Customer" Namespace="AdventureWorks">
      <!—Name of the destination entity in the association -->
<Destination Name="Order" Namespace=" AdventureWorks">
   </Association>
</MethodInstances>

Note

In the interest of brevity and completing this example, LobSystem and LobSystemInstance objects are not shown for the external content type.

See BDCMetadata Schema for the BDC model schema documentation and Business Connectivity Services: Sample XML and Code Examples for more examples.