Code Snippet: Get an Item in an External List By BdcIdentity on the Server
Applies to: SharePoint Server 2010
In this article
Description
Prerequisites
Code
Description
The following code snippet shows you how to get an item by BdcIdentity from an external list.
Prerequisites
Microsoft SharePoint Server 2010 or Microsoft SharePoint Foundation 2010 on the server.
Microsoft Visual Studio.
At least one external content type registered in the BDC Metadata Store.
Code
using System;
using Microsoft.SharePoint;
public SPListItem GetItemByBdcId (SPList list, string bdcIdentity)
{
SPListItem myitem = null;
foreach(SPListItem item in list.Items)
{
if (item["BdcIdentity"].ToString() == bdcIdentity)
{
myitem = item;
}
}
return myitem;
}