Wednesday, October 9, 2013

SharePoint Client Object Model

If the SharePoint is not installed on your machine and how will you connect to SharePoint server and run the application or access information. 

Answer is Client Object Model. The code runs the on client machine instead of server side.

The Client sends and XML request to Server and gets the JSON response from SharePoint server

Using CSOM, you can retrieve, modify the data resides in the SharePoint server

There are 3 type of Object models

  • .NET Managed 
  • Silverlight
  • ECMA Script


The data can be accessed from 

  • .NET application
  • Silverlight Application
  • JavaScript running on Client side


If you want to use the CSOM in your application, you need to add the assemblies depending type of model you are using.

For .NET Managed, you have to add following references.


  • Microsoft.SharePoint.Client.dll and 
  • Microsoft.SharePoint.Client.Runtime.dll


The basic important object which will establish the communication between client and server is ClientContext object.

Example:

ClientContext context = new ClientContext(siteURL);
List mylist = context.Web.Lists.GetByTitle(" My List");
context.Load(list);
context.ExecuteQuery();

No comments:

Post a Comment