We are going to star with managed client object model. Managed client object model works on the .Net CLR. That means any normal application that runs on the .Net CLR installed platform.
I am going to show you by taking windows application as an example and look into some of the very basic stuff to get the web properties.
First create a windows application project and take a reference of two DLLs that are needed to work with.
They are Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll and you can find them 14/ISAPI folder.
public void LoadData()
{
string webUrl = "{site URL}"; //replace this with your site URL
ClientContext context = new ClientContext(webUrl);
Web web = context.Web;
context.Load(web);
context.ExecuteQuery();
this.lblWebTitle.Text = web.Title;
this.lblWebDescription.Text = web.Description;
}
private void button1_Click(object sender, EventArgs e)
{
LoadData();
}
As you can see there is very little difference between server object model and COM as far as classes are concern. SPWeb becomes Web, SPContext becomes ClientContext.
Do remember one thing, until and unless we call executequery method, nothing happens. As soon as executequery method is invoked, then managed client object model bundles up all requests together and then pass it to the server. There is no network traffic till then.

Overall approach with client object model is you bundle up all requests that you want to query to server (web properties, lists properties etc) and then call them at once by invoking executequery method.
We are going to see more and more examples with different approaches. Next is doing same with the help of Silverlight Client.
No comments:
Post a Comment