In the article I will walk through how to use OData, Business Connectivity Services to create a solution for cross site collection list scenarios
For the purpose of this article I created a Site Collection in my environment and named it “Shared”, full URL of this site collection is “http://team.contoso.local/sites/shared”, this site collection also contains a “Contacts” list named “Team Contacts”. Goal is to expose this list to other site collections so you have all the data in one central location and still accessible from other site collections as if the list was available locally within the site collection.
Add a web service reference to your BDC Model project in Visual Studio 2010, see image below
Next we will go ahead and add a BDC model to the project, see image below
Add an entity into your model by choosing the entity option from the toolbox and dragging it on to the design surface. Rename the entity to “Contacts”, add an identifier to the entity, name it “ID” and changed the data type to System.Int32
Using the BDC Method Details window add a finder method to the “Contacts” entity, this will create a “ReadList” method, next we need to change the data type of “Contacts” typedescriptor to use the OData entities generated by Visual Studio 2010 when we added the OData service reference. See image below
Set up additional typedescriptors, see image below
Next create a SpecificFinder method, add “Creator”, “Updater” and “Deleter” If you want to provide full CRUD capabilities.
At this point we are pretty much ready to wire up the entity service class, I have gone ahead and implemented all the CRUD methods. See the code from the entity service class below. Not a whole lot to explain, I’m using OData to perform CRUD operations against the “Team Contacts” list in the shared site collection
Deploy the BCS solution to farm and create an external list called “Contacts” in root site collection “http://team.contoso.local”, I usually provide a site collection scoped feature with a feature receiver that programmatically creates the external list when ever I use .NET connectivity to create my BCS entities.
Image below shows “Team Contacts” list in “Shared” Site Collection
Image below shows the external list “Contacts” created in root site collection, as you can see from the image there is full CRUD support and users can work with the contacts data same way they would if the “Contacts” list was available locally within the site collection, thanks to external list feature within BCS that provides the familiar list like user interface
Couple of things to keep in mind regarding working complex data types in BCS, see this article from BCS team http://blogs.msdn.com/b/bcs/archive/2010/02/10/working-with-complex-data-types-in-business-connectivity-services.aspx also same approach can be used to work around the data access limitation in Sandbox solution, only change would be to leverage secure store in .NET connectivity project
Hope that helps