Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, December 05, 2011

Access BCS entities and methods Programmatically SharePoint 2010

This post we will see an example for accessing Business Connectivity Services or BCS entities and its methods using Client object model.
Assumptions – Already have an External content type setup
private static void BrowseCatalogDetails()
{
Console.WriteLine(“Now Browsing the all the entities in the catalog:”);
AdministrationMetadataCatalog catalog = AdministrationMetadataCatalog.GetCatalog(siteUrl);
EntityCollection entities = catalog.GetEntities(“*”, “*”, true);
Console.WriteLine(“\nEntities in the system:”);
foreach (Entity entity in entities)
{
Console.WriteLine(entity.Name);
}
// Browsing through the first entity
var entityEnum = entities.GetEnumerator();
entityEnum.MoveNext();
Entity firstEntity = entityEnum.Current;
Console.WriteLine(“\nMethods on the first Entity:”);
foreach (var method in firstEntity.Methods)
{
Console.WriteLine(method.Name);
}
}
The above code is to access the SharePoint entity catalog. To get a specific entity use
IEntity entity = catalog.GetEntity(siteUrl, “MyexternalContentType”);

No comments:

Post a Comment