Condividi tramite


XML Snippet: Modeling an Updater Method

Applies to: SharePoint Server 2010

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

Example

<Method Name="Update" DefaultDisplayName="SalesReason Update">
  <Properties>
    <Property Name="BackEndObject" Type="System.String">
      SalesReason</Property>
    <Property Name="BackEndObjectType" Type="System.String">
      SqlServerTable</Property>
    <Property Name="RdbCommandText" Type="System.String">
      UPDATE [Sales].[SalesReason] 
      SET [Name] = @Name , [ReasonType] = @ReasonType , 
      [ModifiedDate] = @ModifiedDate 
      WHERE [SalesReasonID] = @SalesReasonID</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>
  <Parameters>
    <Parameter Direction="In" Name="@SalesReasonID">
      <TypeDescriptor TypeName="System.Int32" 
                      UpdaterField="true" 
                      IdentifierName="SalesReasonID" 
                      Name="SalesReasonID" />
    </Parameter>
    <Parameter Direction="In" Name="@Name">
      <TypeDescriptor TypeName="System.String" 
                      UpdaterField="true" 
                      Name="Name">
        <Properties>
          <Property Name="Size" Type="System.Int32">50</Property>
        </Properties>
        <Interpretation>
          <NormalizeString FromLOB="NormalizeToNull" 
                           ToLOB="NormalizeToEmptyString" />
        </Interpretation>
      </TypeDescriptor>
    </Parameter>
    <Parameter Direction="In" Name="@ReasonType">
      <TypeDescriptor TypeName="System.String" 
                      UpdaterField="true" 
                      Name="ReasonType">
        <Properties>
          <Property Name="Size" Type="System.Int32">50</Property>
        </Properties>
        <Interpretation>
          <NormalizeString FromLOB="NormalizeToNull" 
                           ToLOB="NormalizeToEmptyString" />
        </Interpretation>
      </TypeDescriptor>
    </Parameter>
    <Parameter Direction="In" Name="@ModifiedDate">
      <TypeDescriptor TypeName="System.DateTime" 
                      UpdaterField="true" 
                      Name="ModifiedDate">
        <Interpretation>
          <NormalizeDateTime LobDateTimeMode="UTC" />
        </Interpretation>
      </TypeDescriptor>
    </Parameter>
  </Parameters>
  <MethodInstances>
    <MethodInstance Type="Updater" 
                    Name="Update" 
                    DefaultDisplayName="SalesReason Update" />
  </MethodInstances>
</Method>

For a complete BDC model sample that includes an Updater, 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.