Pages

Wednesday, 6 November 2013

Business Connectivity services using Visual Studio 2010

Using SharePoint
Designer you can connect and communicate to external Database or Data. But you
don’t have much control using SharePoint 2010 designer.

Other option is you
can use Visual studio to write custom code to achieve External Content type.
Using Custom code you have full control over the business logic to external Data
Sources.How it Works

BDC Runtime API which
manipulate the External data, External content type behave similar like a
SharePoint content types, you can manage security on external Lists, Default
farms for add, edit, and delete are created , List are available for BI
solution, Data in Lists are available for Search.

How to Create BCS Solution in Visual Studio 2010

1.First we need to identify the Data
Store/Database which we want to use as external Content type, in this example I
am using very simple table with the name of Customers which contain only 3
columns. Database Table script is

21.Expand the ReadItem
Method and Expand the Copy the Customer Entity for Return parameter (as we
define it earlier so no need to do this effort again ).

22.Copy to ReadList
Method Return Parameter and Rename EntityList1 to Customers and Paste entity to
Customers.

Till we have done to
get specific Item Method (readItem) and get All items (ReadList), Now we are
looking to create Creator method.

23.Select the model Open
the Propertied and select the Creator Method from Dropdown. And click on it. It
will setup everything (in previous method we need to define entity it will
setup automatically).

No do same step for Deleter
and Updater Methods. Just select Model Diagram and open the BDC Model Detail
Pain and select Deleter and Updater, it will configure everything in default
based on our previous settings. And your Detail View look like Below
screenshot.

This is all that we need
to do using designer, now open the Code view (CustomerModelService.cs Class).
And see it there are 5 methods now we have to write the code for Create,
update, delete, readList and ReadItem methods.

Here you can write
code with any logic, I am using very simple ADO.Net Method to perform these
actions.

Here is My Code …
Again – (here you can use your own way to write the Code. And you own logic)