SharePoint Blog - René Hézser

Anmelden  RSS Feed RSS Feed
Startet die Suche

Archive

Kategorien

Links

Andere Blogs




ITaCS GmbH


Using a custom field type in a BCS model  

May 172010

The BCS Team (Business Connectivity Services) wrote an blog post about using complex formatting and custom field types within your BCS model. Obviously this post was the source for the SDK article.

The example shows that you can use a custom field type to render data from external data sources this way:

<TypeDescriptor TypeName="Customer.Address" Name="CustomerAddress" DefaultDisplayName="Customer Address"> 
   <Properties> 
       <Property Name="SPCustomFieldType" Type="Customer.Address">Customer Address</Property> 
   </Properties> 
</TypeDescriptor> 

Well, to help you map this example to your data, I’ll write some more about the SPCustomFieldType property of the BCS model.

This is how a method would look like, if you want to map a column to a custom field type:

<Method Name="ReadItem">
  <Parameters>
    <Parameter Name="address" Direction="Return">
      <TypeDescriptor Name="Address" TypeName="RH.SharePoint.BCS.Address, BCSModel">
        <TypeDescriptors>
          <TypeDescriptor Name="Id" IdentifierName="Id" TypeName="System.Int32" />
          <TypeDescriptor Name="Street" TypeName="System.String" />
          <TypeDescriptor Name="Number" TypeName="System.String" />
          <TypeDescriptor Name="PostalCode" TypeName="System.String" />
          <TypeDescriptor Name="City" TypeName="System.String" />
          <TypeDescriptor Name="GeoCoordinates" TypeName="System.String">
            <Properties>
              <Property Name="SPCustomFieldType" Type="System.String">GeoCoordinates</Property>
            </Properties>
          </TypeDescriptor>
        </TypeDescriptors>
      </TypeDescriptor>
    </Parameter>
    <Parameter Name="id" Direction="In">
      <TypeDescriptor Name="Id" TypeName="System.Int32" IdentifierEntityName="Address" IdentifierEntityNamespace="RH.SharePoint.BCS.Model" IdentifierName="Id" />
    </Parameter>
  </Parameters>
  <MethodInstances>
    <MethodInstance Name="ReadItem" Type="SpecificFinder" ReturnParameterName="address" ReturnTypeDescriptorPath="Address" />
  </MethodInstances>
</Method>

“GeoCoordinates” is the name of my custom field type, specified by <Field Name="TypeName">GeoCoordinates</Field>.

The data source for this BCS model is a LINQ to SQL class, where I’ve implemented a property to concatenate the latitude and longitude which are stored in the backend system.

public string GeoCoordinates
{
  get
  {
    if (Latitude == null || Longitude == null) return null;
    return string.Format("{0};{1}", Latitude, Longitude);
  }
}
 
Posted by René Hézser | 1  Comment | Trackback Url  | 0  Links to this post | Bookmark this post with:        
Tags: SharePoint, BCS

Links to this post

Comments

commented on  Thursday, April 07, 2011  1:00 PM  by  Kedrick
Hi,

I'm having a lot of problems creating a BCS Model with custom field types. I'm able to create the ECT and deploy to SharePoint. However, whenever I try to create a list using the ECT, I get an error <nativehr>0x80131600</nativehr><nativestack></nativestack> along with a stack trace that I can't make any sense of!

Have you seen this error before? Can you give me any help on it?


Thanks,
Kedrick

Name *:
URL:
Email:
Kommentar:


CAPTCHA Image Validation