Translate

Sunday, August 7, 2011

Sharepoint Object Model

Introduction to Sharepoint Object Model


Sharepoint Object Model can be implemented using both at client and at server side where in sharepoint 2010 introduce the Client Object Model,
Sharepoint object model is heart of sharepoint programming and sharepoint stuff,it is mainly deals with Sharepoint Objects which i am going to disscuss more in next few minutes

Microsoft Company has spent a very huge amount of time developing .NET namespaces for SharePoint which includes both the versions Moss 2007 and Sharepoint 2010.
Since Microsoft has provide a set of namespaces which allows programmer to have an access to a Windows Sharepoint Services or Sharepoint Foundation and Sharepoint 2010 or Sharepoint 2007
The SharePoint Services object model is extensive, to say the least.
There are lots of namespaces within the object model and dozens of classes covering most of the
features of SharePoint 2010 and 2007. To understand the architectural design makes it impractical to study the object model directly. Instead of that it is better to use the object model to solve categories of solutions that we are creating.

using the objects in the SharePoint model is done in a similar manner as we do to any hierarchical object model
The key to navigating such a model
is to find the starting point for the model. In SharePoint, this is done through the ASP.NET
Context object using the following code:
SPSite site = SPControl.GetContextSite(Context);
there is one more class SPControl which inherities from the namespace Microsoft.SharePoint.WebControls,we are not required to create an instace of the Spcontrol object,simply use GetContextSite method provided and use and pass the Context property
which comes from the namespace System.Web.UI.Page,which will available to Webpart and Pages

site collection which holds all lists and other stuff.
SPSite objects contain information about the site collection and the sites within it. In
order to access any particular site in the collection, you must return a collection of SPWeb
objects. You may then access the individual web sites by enumerating them or accessing
one directly through an index like
SPWeb site = SPControl.GetContextWeb(Context);

Accessing Lists and List Items

Usually site collections,holes information about access lists and list items ,where we use mainly to accss list information frequently.When we are working with mainly
with lists,we are interested in a particular site rather than a site collection. Usually we do a
a reference to an individual site by using the GetContextWeb method of the SPControl object.
Once a site is open,We may access all of the lists it contains through the SPListCollection
object. Each site collection holds an SPList object for every list on the web site. Let us consider the example of partial code sample

SPWeb site = SPControl.GetContextWeb(Context);
SPListCollection lists= site.Lists;
foreach(SPList list in lists)
{
//add code here
}
I just list out the few lists here where we use object model more frequently
Annocement List
DiscussionBoard
DocumentLibrary
GenericList
Issue
Survey

Will be discuss more in future posts

No comments:

Post a Comment