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.
Showing posts with label BCS. Show all posts
Showing posts with label BCS. Show all posts

Tuesday, July 17, 2012

Business Connectivity Services

Business Connectivity Services (BCS) enables SharePoint to access data from external data systems such as SAP, ERP, and CRM, in addition to other data-driven applications that are exposed through WCF services or OData endpoints. BCS in SharePoint 2013 Preview has been improved and enhanced in many ways, including OData connectivity, external events, external data in apps, filtering and sorting, support for REST, and others.

Monday, December 05, 2011

Get data from bcs external content type in SharePoint 2010 Programmatically

Here is short example of how to execute a method on an entity Programmatically. Assuming you already have a External content type “My External content type” setup to a Sql database lets look at a console application
private static void ExecuteMethod()
{
Console.WriteLine(“\nNow Executing methods”);
using (SPSite site = newSPSite(siteUrl))
{
using (newSPServiceContextScope(SPServiceContext.GetContext(site)))
{
BdcService service = SPFarm.Local.Services.GetValue();
IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);
IEntity entity = catalog.GetEntity(siteUrl, “My External content type”);
ILobSystemInstance LobSysteminstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value;
IMethodInstance method = entity.GetMethodInstance(“Read List”, MethodInstanceType.Finder);
IEntityInstanceEnumerator handle = entity.FindFiltered(method.GetFilters(), LobSysteminstance);
Console.WriteLine(“Title in My External content type:”);
while (handle.MoveNext())
{
Console.WriteLine(handle.Current["Title"].ToString());
}
}}}

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”);

What is Business Connectivity Services in SharePoint ?

SharePoint 2010 provides a new set of technologies known as Business Connectivity Services for retrieving, editing, updating, and deleting data from external systems(for e.g. data from ERP or CRM database). BCS enhances the SharePoint platform’s capabilities with out-of-box features, services and tools that streamline development of solutions with deep integration of external data and services.