Monday, July 12, 2010

ADO.Net Connection to Enterprise Enabler

ADO.Net framework (API) for Enterprise Enabler (EE) allows users to connect to enterprise enabler and get integrated data from different data sources in any ADO.Net enabled platform.

ADO.Net API uses application definition generated in the EE studio.

Generating EE Application Definition.

EE Application definition Tool is used to create application definition for SharePoint 2010, SharePoint 2007 and wss.

Prerequisites

1. Source template or map.

2. Source Template or Destination Template should have only one block (Data will be shown only from one block).

3. Destination template block name will be used as the entity name in application definition.

4. Created objects should be deployed to the server. (Go to deployment manager and deploy the objects)

Steps to Create Application Definition.

1. Log in to Enterprise Enabler Studio.

clip_image002[10]

2. Create templates and maps as required.

clip_image004[8]

3. Deploy these objects to server by Clicking Deployment Manager menu button under Server menu.

clip_image006[8]

clip_image008[8]

4. Go to File -> New -> EE App Def -> EE Data Model.

clip_image010[8]

clip_image012[6]

5. Give a valid name for application definition. (This will be used in the connection string as Initial Catalog)

6. Click on Add Entity to create Entity.

a. If the map is already created, you can select that map to add entity.

b. If source template is available, you can create map automatically.

c. If CRUD operations are needed, you can auto generate update maps by checking the Auto Generate Edit Maps option.

d. Entity name will be selected from the destination template block name.

clip_image014[6]

clip_image016[6]

7. Once everything is ready, click on Connection String button in ADO.Net section to get the connection string.

clip_image018[6]

clip_image020[6]

8. Copy the connection string and exit the screen.

Accessing data using Enterprise Enabler ADO.Net API

Use the following API to access the application definition created in the above screen.

using (EEConnection conn = new EEConnection("CONNECTION STRING"))

{

conn.Open();

EECommand command = new EECommand("QUERY", conn);

DataTable table = new DataTable();

table.Load(command.ExecuteReader());

dataGridView1.DataSource = table.DefaultView;

}

Replace CONNECTION STRING with the connection string copied in the above screen. Replace QUERY with a valid query like Select * from CustomCustomers.

Here CustomCustomers is the entity name selected in the application definition.

Here is the sample application screen shot, which shows the connection string, query and data from the map.

clip_image022[6]