Extending Search with the Connector Framework
Connectors are the new way for you to surface custom data stores into search. An existing BDC connector will be changed to make it work in Search.Source Code for the same is embedded at bottom.
|The project in the starter files is contains a BDC Connector and is developed using the new Visual Studio 2010 SharePoint Tools.||Open the project CreatingConnector in Visual Studio 2010. |
The project item used to create the model is the Business Data Connectivity model.
Double-click the BdcModel1 item to open it in the Designer. The modeled entity is called Product and has an identifier and 2 methods.
When you click one of the methods, you see the BDC Method Details explorer at the bottom of the Visual Studio 2010 environment. You can see the different parameters, descriptors, and so on. You can make changes to the methods in this explorer.
Notice also the BDC Explorer on the right side of the Visual Studio 2010 environment. You can navigate through the tree view and see the properties of the different nodes in the Properties window.
Return to Solution Explorer and expand the BdcModel1 node. Double-click the Entity1.cs file to view the code. Notice that there are 3 properties defined:
Double-click the ProductService.cs file to view the code.
Scroll down to the ReadItem method, which is defined in the model. The incoming argument for this method is an id. This method returns one object of type Entity1. This method uses LINQ to XML to retrieve the products. The where clause specifies the ID of the product that must be returned. When the product is found it is populated and returned to SharePoint.
Right below there is the ReadList method. This method has no incoming arguments and returns a collection of Entity1 objects. It also uses LINQ to XML to retrieve the products. A list of products is created and returned to SharePoint.
Both methods call the private method GetData. For demo purposes this method contains some inline XML that represents a list of 4 products from 3 different companies.
|As with the other types of SharePoint projects you can deploy to SharePoint from within Visual Studio 2010.||Select the project in Solution explorer and check the Properties window. |
If you want to deploy to another SharePoint site than http://intranet.contoso.com you can change the Site URL property.
Right-click the project in Solution Explorer to start the deployment.
|BDC Model projects are deployed to the Business Data Connectivity Service. Objects of that type can be used the same way as external content types. |
Using this type of .NET assembly connector you can gain a lot of control over the list and the list items. You could add item level security to it if necessary.
|Open the SharePoint Central Administration. |
Navigate to Application Management and choose Manage Service Applications.
Open the Business Data Connectivity page. Notice that the Product is there.
You can use this type the same way as an external content type.
Navigate to your SharePoint site and create a new list based on the External List template. Give it the name ECT_Products and select the BdcModel1 as external content type.
Click the Create button.
All the products from the inline XML document are displayed in the list.
You can view the items in the list. You can also create the additional methods to update existing products or add new ones.
Post a Comment