SharePoint 2007 Object Model


SharePoint 2007 Object Model

Through SharePoint object model programmatically access the SharePoint data into asp.net or any other server process. To access the SharePoint data we need to add SharePoint Microsoft.SharePoint.dll which is found under

 <Installed Drive>:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\

SharePoint object model grouped in two categories:

1. Server Architecture
2. Site Architecture

Server Architecture Object Model: The server architecture object model access “Microsoft.SharePoint.Administration” Namespace
1.        1. Farm
a.        SPFarm
2.        2. Server
a.        SPServer
3.        3. Services
a.        SPServices
4.        4. Web Service
a.        SPWebService
5.        5. Database Service Instance
a.        SPServiceInstance
b.        SPDatabaseServiceInstance
6.        6. Web Applications
a.        SPWebApplication
b.        SPAdministrationWebApplication
7.        7. Content DataBase
a.        SPDatabase
b.        SPContentDatabase
8.        8. SiteCollection
a.        SPSite

Site Architecture Object Model:All Site Architecture objects and collections are available in the “Microsoft.SharePoint” namespace.

1.        Site Collection: This collection of sites is known as “Site Collection”.

SPSite object can be instantiated by following methods

·   SPSite objSPSite = new SPSite("Site URL");

·   SPSite objSPSite = SPContext.Current.Site;

·   SPSiteCollection objSiteCollection = objWebApplication.Sites;

int index = 0;

SPSite objSite = objSiteCollection[index];

2.    Sub Sites: Each SharePoint website is represented by SPWeb object whether it is a top level website or a sub site. SPWeb object has a Webs property that returns a collection of other SPWeb objects

  SPWeb object can be instantiated by following methods

 a.        SPSite objSPSite = new SPSite("Site  URL");

SPWeb myWeb = objSPSite.OpenWeb();

3.                 3.  List(Each SPList object has members that are used to manage the list or access items in the list)
                            SPList myList = myWeb.Lists["My First List"];
4.                 4Fields: Each SPField object has members that contain settings for the field
         SPList mylist = myweb.Lists.TryGetList("Announcements");
                                               SPField fld = mylist.Fields[SPBuiltInFieldId.Expires];
5.                5.  List Item: Represents a single row in the list
          SPList myList = myWeb.Lists["My First List"];
                                               SPListItem myListItem = myList.Items[5];

Comments

Popular posts from this blog

Display multiple marker point on Google Map with same location or same Longitude,Latitude

Implementing Zoom functionality in asp.net

Check Session Timeot for Whole Application