Monday, December 14, 2009

SharePoint 2010 – Client Object Model

The SharePoint 2010 Client Object Model feature is definitely in my top 10 list of SharePoint developer enhancements. It basically provides an abstraction layer so that client apps can interact with SharePoint – there are basically 3 flavors of Client Object Models:

  1. For .Net managed clients – uses the Microsoft.SharePoint.Client.dll in the “14\ISAPI” folder
  2. For Silverlight clients – uses the Microsoft.SharePoint.Client.Silverlight.dll from the “14\LAYOUTS\ClientBin” folder.
  3. For Javascript client code – using the SP.js file from the “14\LAYOUTS” folder.

These 3 client models all talk with SharePoint through the client.svc WCF service and all provide complete access to SharePoint artifacts such as site collections, sites, lists, items, files, folders, webparts, security, content types, etc …

If you need to retrieve data you will typically have 3 steps you need to perform:

  1. Create a connection using the ClientContext object
  2. Create a select statement and provide it to the ClientContext.Load method – you might want to take a look at how to create LINQ queries with Lambda expressions since you will need this in more advanced scenarios e.g. ctx.Load(w.Lists, lists => lists.Include(prop => prop.Title, prop => prop.Id, prop => prop.Hidden));
  3. Execute the query using ClientContext.ExecuteQuery

There is a great series of blog postings from Steve Peschka about practical use of the Client OM:

1 comment:

Anonymous said...

You can find some list of articles on SharePoint 2010 client object model here.
COM complete details:
ECMAScript- Client OM:
ECMAScript - How to know all methods:
ECMAScript - Small Example:
LoadQuery vs Load:
Managed ClientOM:
Silver light Client OM: