Blogroll

Monday, August 13, 2012

SharePoint 2010 Object Model Classes

Microsoft SharePoint Server 2010 offers a highly structured server-side object model that makes it easy to access objects that represent the various aspects of a SharePoint Web site. From higher-level objects, you can drill down through the object hierarchy to obtain the object that contains the members you need to use in your code. Reference

Here there are some SharePoint Object model classes.

In the top SPFarm class is there.

SPFarm: This reference the entire SharePoint Server Farm.
By using this you can create a new farm or you can connect to a existing a existing farm.

Namespace: Microsoft.SharePoint.Administration

SPServer: By using this class you can browse through the collections of servers belongs to the Farm.

SPSite: Represent a Site collection.

SPWeb: Represent a web site.

SPUserToken: The SPUserToken class represents a token for a valid SharePoint user.

SPList: SPList corresponds to a single list instance, whether that is a list of items or a document library.

SPListItem: This defines a reference to a specific item of a list.

SPDocumentLibrary: This type represents a document library.

SPFile: This class is used to enumerate the files contained in a document library.

SPPrincipal: This class is the parent class for SPGroup and SPUser.

SPControl: This class we need while developing web controls or Web Parts.

SPContext: This is a very useful class and it has some direct methods to access useful information about current requests.

Different DLLs for Client Object Model SharePoint

There are different client object model like managed client object model, ECMAScript object model, Silverlight client object model etc. To work with these object models SharePoint provides certain classes which exists inside some dlls. These dlls are very leightweight as compared to SharePoint server object model. So it is a good idea to know about the dlls used and there locations.

Managed Object Model:

Dlls needed:

- Microsoft.SharePoint.Client
- Microsoft.SharePoint.Client.Runtime

Location: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI (If SharePoint installation done in C drive)

ECMAScript Object Model:

JS needed:

- SP.js , SP.Core.js , SP.Ribbon.js , and SP.Runtime.js .

Location: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS (If SharePoint installation done in C )

Silverlight Object Model:

Dlls needed:

- Microsoft.SharePoint.Client.Silverlight
- Microsoft.SharePoint.Client.Silverlight.Runtime

Location: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin (If SharePoint installation done in C drive)drive)

Client Object Model SharePoint 2010 Details:

MOSS 2007 provides Web services which are difficult to use and always returns XML documents and XML data needs to be parsed manually.

These are simple APIs to add, retrieve, update and manage data in SharePoint. There are some tasks you can not do using client object model like creating a web application.

These classes are very easy to use and prefix sp is removed in the naming of client object model classes. For example in Server object model if the class is SPList now in client object model the class name is List.

Behind the schene client object model interact with some wcf services to communicate with SharePoint.

To work with client object model you need to refer 2 dlls which can be found in the following locations, refer to Managed Object Model, as discussed above:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI

The 2 dlls are:

- Microsoft.SharePoint.Client.dll
- Microsoft.SharePoint.Client.Runtime.dll

Here is an example to create a list of type Announcement list by using SharePoint 2010 client object model.

using (ClientContext context = new ClientContext(http://Amardeep:8787/sites/Training))

{  //Create a new list

ListCreationInformation listCreationInformation = new ListCreationInformation();

listCreationInformation.Title = "My Announcements List";

listCreationInformation.Description += "Here is my list created by client object midel";

listCreationInformation.TemplateType = (int)ListTemplateType.Announcements;

listCreationInformation.QuickLaunchOption = Microsoft.SharePoint.Client.QuickLaunchOptions.On;

List list = context.Web.Lists.Add(listCreationInformation);

context.ExecuteQuery();
}

More Details: Refer to the link.

No comments:

ShareThis

snow flakes

blogger widgets Blogspot Tutorial

LinkWithin

Related Posts Plugin for WordPress, Blogger...