Home  > Resources  > Blog

SharePoint Development– Object Model

December 15, 2013 by Faheem Javed
Category: Microsoft

For SharePoint development we rely on a bunch of classes. These classes are collectively known as Object Model. By using these classes we can perform various activities e.g. create site collections / sub-sites, libraries, lists, upload documents, add list items, delete items, create taxonomy / metadata / content types etc.


Object model is of two main types:

  1. Server Object Model
  2. Client Object Model

Server Object Model

Server Object Model means we get to create program in C# / VB.NET and the code is deployed to SharePoint server as a wsp package.  In short the code runs on the same server where SharePoint is deployed. We can also use PowerShell for utilizing server object model.

Here’s the server object model hierarchy:

* SPFarm (enumerate services, solutions, CurrentUserIsAdministrator)
    * SPService (represents a service. e.g. Excel Service, InfoPath Form service etc.)
        * SPWebApplication (represents the IIS web application)
            * SPSite (represents site collection)
                * SPWeb (represents site / sub-site)
                   * SPList (represents list / library)
                        * SPListItem (represents list item or document)

Here are some more useful classes:

SPField (represents field / column in a list or library. e.g. Link, Choice, …)
SPContentType (represents content type)
SPUser (represents SharePoint user)
SPSecurity (security,  elevated permissions, exception handling)
SPQuery (used for running CAML queries for querying lists and libraries)
SPContext (easier way to retrieve current site)
SPGroup (represents SharePoint security group)
UserProfileManager (useful for manipulating user profiles and mysite)
Taxonomy (Term Store. Hierarchical metadata)
    * TaxononmySession
    * TermStore
    * Group
    * TermSet
    * Term

Client Object Model

Client Object Model allows us to write code in  C# / VB.NET / JQuery etc. The code can reside on any machine and we can still access SharePoint located on a remote server.  Here are some useful client object model classes:

ClientContext (specify the SharePoint site we want to connect to. Pass credentials to the site)
Web (represents an existing site / sub-site)
WebCreationInformation (used for creating a new site /sub-site)
NavigationNodeCreationInformation (used for configuration navigation / top link bar)
List (represents an existing list or library)
ListCreationInformation (used for creating a new list or library)
ListItemCreationInformation (used for creating a new list item)
ListItem (represents an existing list item)
FileCreationInformation (used for creating a new document in a library)

Follow Us

Blog Categories