Condividi tramite


XML Snippet: Modeling an IdEnumerator Method

Applies to: SharePoint Server 2010

The following is an example of an IdEnumerator method in a BDC model.

Example

<Method Name="Id Enumerator" DefaultDisplayName="Customer Id Enumerator">
  <Properties>
    <Property Name="BackEndObject" Type="System.String">
      Customer</Property>
    <Property Name="BackEndObjectType" Type="System.String">
      SqlServerTable</Property>
    <Property Name="RdbCommandText" Type="System.String">
      SELECT TOP(@ItemsLimit) [CustomerID] FROM [Sales].[Customer]
    </Property>
    <Property Name="RdbCommandType" Type="System.Data.CommandType, 
              System.Data, Version=2.0.0.0, Culture=neutral, 
              PublicKeyToken=b77a5c561934e089">Text</Property>
    <Property Name="Schema" Type="System.String">Sales</Property>
  </Properties>
  <FilterDescriptors>
    <FilterDescriptor Type="Limit" FilterField="CustomerID" 
                      Name="MaxCustomers">
      <Properties>
        <Property Name="CaseSensitive" Type="System.Boolean">false</Property>
        <Property Name="IsDefault" Type="System.Boolean">true</Property>
        <Property Name="UsedForDisambiguation" Type="System.Boolean">false</Property>
      </Properties>
    </FilterDescriptor>
  </FilterDescriptors>
  <Parameters>
    <Parameter Direction="In" Name="@ItemsLimit">
      <TypeDescriptor TypeName="System.Int64" AssociatedFilter="MaxCustomers" 
                      Name="MaxCustomers" DefaultDisplayName="MaxCustomers">
        <DefaultValues>
          <DefaultValue MethodInstanceName="Id Enumerator" 
                        Type="System.Int64">2000</DefaultValue>
        </DefaultValues>
      </TypeDescriptor>
    </Parameter>
    <Parameter Direction="Return" Name="Id Enumerator List">
      <TypeDescriptor TypeName="System.Data.IDataReader, System.Data, 
                      Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
                      IsCollection="true" Name="Id Enumerator List">
        <TypeDescriptors>
          <TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, 
                          Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
                          Name="Id Enumerator ListElement">
            <TypeDescriptors>
              <TypeDescriptor TypeName="System.Int32" ReadOnly="true" 
                              IdentifierName="CustomerID" Name="CustomerID" />
            </TypeDescriptors>
          </TypeDescriptor>
        </TypeDescriptors>
      </TypeDescriptor>
    </Parameter>
  </Parameters>
  <MethodInstances>
    <MethodInstance Name="Id Enumerator" Type="IdEnumerator" 
                    ReturnParameterName="Id Enumerator List" 
                    DefaultDisplayName="Customer Id Enumerator">
      <Properties>
        <Property Name="BatchByDefault" Type="System.Boolean">true</Property>
      </Properties>
    </MethodInstance>
  </MethodInstances>
</Method>

For a complete BDC model sample that includes an IdEnumerator, do the following:

  1. Download the Microsoft SharePoint 2010 SDK.

  2. Extract "bcs sample kit.zip" from "%ProgramFiles%\Microsoft SDKs\SharePoint 2010\Samples\Business Connectivity Services" to a local folder.

  3. In the folder where you extracted the files, locate the "BDC Models for XML Snippets" folder. This folder contains BDC model samples.