Before comparing performances between ADO.NET Data Services and the Client Object Model Service, we will go through a small review on both technologies.
ADO.NET Data Services (listdata.svc)
- Strongly typed
- Use of the Open Data Protocol (OData) : requests and writes in JSON, ATOM. The response format depends on the http headers of your GET request (set type = application/json will return JSON)
- You can query only list data and write to lists. You can not retrieve for instance properties of an SPWeb, SPSite, Users,…
- Does not work with External List
- (You can not query more than 1000 items at a time (except if you use Data Paging))
The best news for the SharePoint developer it’s that ADO.NET Services is now part of the SharePoint Platform. All what you need to do is to install this.
How does it work?
Once ADO.NET Data Services installed on your SharePoint, you will get a new WCF in the _vti_bin virtual directory of SharePoint: listdata.svc. Note that the _vti_bin directory points to the %ProgramFiles%/Common Files/Microsoft Shared/Web Server Extensions/14/ISAPI folder.
If you query this Web Service with your favourite browser (i.e. http://<sharepointUrl>/_vti_bin/listdata.svc), you will see a listing of all the lists of the SharePoint Site written in a standard Data Services Atom Feed. If you create a custom list, it will also appear there.
To use the capabilities of this new feature, you just simply need to reference it in your .NET project as you would do with a standard WCF.
Visual Studio – Right-Click on a Project or on References – Add Service Reference – http://<sharepointUrl>/_vti_bin/listdata.svc
Note that the lists made available through the listdata.svc will depend on which SharePoint Site you are calling it. So if you have a SharePoint site A – http://sharepointUrl/siteA and a SharePoint site B – http://sharepointUrl/siteB, be sure to append _vti_bin/listdata.svc at the end of the url (ex. http://sharepointUrl/siteA/_vti_bin/listdata.svc)
Client Object Model (client.svc)
- Provides a common API to request SharePoint seamlessly from Silverlight, ECMAScript or any .NET Managed Client
- Offers a new way of programming SharePoint 2010
- Instead of having a lot of useless Web Services, it gives you an access directly to the data
- Works with External List
- Not strongly typed as it returns SPListItem
How does it work?
The Client Object Model is used through the Client.svc WCF Service published into the virtual directory _vti_bin (%ProgramFiles%/Common Files/Microsoft Shared/Web Server Extensions/14/ISAPI).
Unlike the ADO.NET Data Services, the Client.svc is not to be used directly, you can try add a Service Reference in Visual Studio pointing to http://<sharepointUrl>/_vti_bin/Client.svc, you won’t be able
to generate a proxy client for this Service and that’s why the Client Object Model takes place. it will act as a proxy between the client and the Client.svc service
As I said before, the Client Object Model is accessible from ECMAScript, Silverlight or any .NET Managed Client
– It can be used only in SharePoint Site, you cannot reference this file in a classic ASP.NET Site due to cross-scripting issue
– You cannot make cross-site query due the same issue
– JQuery and SP.js works fine together
for Silverlight you must add the reference to Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll located under %ProgramFiles%/Common Files/Microsoft Shared/Web Server Extensions/14/TEMPLATE/LAYOUTS/ClientBin
for any other .NET Manage Client you must add a reference to Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll located under %ProgramFiles%/Common Files/Microsoft Shared/web server extensions/14/ISAPI
I’ve made a small performance test to compare ADO.NET Data Services and the Client Object Model.
The test scenario is really simple and defined as following:
I created a custom list called movies and query the list using ADO.NET Data Services and Client Object Model 20 times.
– Query this List using ADO.NET Data Services
The requested url is as following : _vti_bin/ListData.svc/Movies()?$select=Director,Title,Year
Size of the XML response : 680k
Time to retrieve : ~0.527 seconds
– Query this List using Client Object Model
Size of the JSON response : 256 K
Time to retrieve : ~0.375 seconds
Note that the RowLimit is set to 1000, indeed ADO.NET Data Services can not retrieve more than 1000 item at a time so I set the limit at 1000 items also for the Client Object Model request to run a benchmark on the same number of items.
The results I found speak for themselves. The Client Object Model is slightly faster than the ADO.NET Data Services.