Welcome Guest |
Login
|
Register
Custom Search
A web planet of technical resources
Home
Technology Blogs
Videos
Code Snippets
Interview Questions
Web Tools
Contact
Overview of SharePoint Object Model
Posted By:
eTechPlanet
Tags:
sharepoint object model
,
moss object model
,
moss 2007 object model
,
sharepoint architecture
,
moss architecture
,
moss 2007 architecture
,
sharepoint
,
moss 2007
Category:
SharePoint
Published:
August 28, 2009
Last Modified:
July 30, 2010
Page Views:
999
E-mail
|
Comments (0)
SharePoint offers a set of structured server-side objects those are widely used to program SharePoint Applications. These objects are hierarchically arranged and you can drill down through the object hierarchy to obtain the object that contains the components of SharePoint Application you need to use in your code.
SharePoint object model can be grouped in two categories:
1. Object model of Server Architecture
2. Object model of Site Architecture
Object model of Server Architecture:
Following diagram shows the Windows SharePoint Services server architecture in relation to the SharePoint objects and collections. All these objects and collections are available in the “
Microsoft.SharePoint.Administration
” namespace.
SPFarm Object
SPFarm
object is the highest object within the Windows SharePoint Services object model hierarchy which represents a WSS farm and
used for central configuration settings. It contains global settings for all the servers, services, and solutions that are installed in a WSS farm. With this object you can also access all the servers, services, and solutions that are installed in a WSS farm.
·
Create method can be used to a server farm, its associated configuration database, and a farm account on the local computer based on the specified connection string.
·
Open method can be used to get a remote server farm based on the specified connection string.
·
Servers property of SPFarm object is used to get the collection of all physical computers that are in the server farm. This property returns a SPServerCollection object which is a collection of SPServer objects (one SPServer object for each physical computer in the current server farm).
·
Services property of SPFarm object is used to get the collection of all the services that are in the server farm. This property returns a SPServiceCollection object which is a collection of SPService objects (one SPService object for each Service in the current server farm).
·
Solutions property of SPFarm object is used to get the collection of all the solutions that are in the server farm. This property returns a SPSolutionCollection object which is a collection of SPSolution objects (one SPSolution object for each Solution in the current server farm).
SPServer Object
SPServer object represents a physical computer in the server farm.
ServiceInstances
property is used to get the collection of individual service instances that run on the individual computer.
SPService Object
SPService object represents a logical service or application installed in the server farm.
SPSolution Object
SPSolution object represents a SharePoint Solution installed in the server farm.
SPWebService Object
SPWebService object represents a Web service that contains one or more WSS web applications. It can be used to access configuration settings for a specific logical service or web application.
WebApplications
property is used to get the collection of all the web applications that are running within this service. It returns SPWebApplicationCollection object which is a collection of SPWebApplication objects (one SPWebApplication object for each web application).
SPServiceInstance Object
SPServiceInstance object represents a single instance of service running in the server computer.
ServiceInstances
property of the SPServer object can be used to get the
SPServiceInstanceCollection
object that represents all the service instances that are currently running on a server computer.
Service
property is used to get the
SPService
object that contains the farm-wide settings that apply to the service that this instance implements.
Server
property is used to get the
SPServer
object on which this instance is installed.
SPDatabaseServiceInstance Object
SPDatabaseServiceInstance
object represents a single instance of a database service running on the server computer. The SPDatabaseServiceInstance class derives from the
SPServiceInstance
class and thus inherits the
Service
property, which provides access to the service or application that the instance implements. The
Databases
property gets the collection of content databases used in the service.
SPWebApplication Object
SPWebApplication object represents a WSS web application and it contains a set of content databases and site collections. The SPWebApplication object provides access to credentials and other server farm wide application settings
SPWebApplication inherits from
S
PPersistedObject
, which means that an object of the class persists in the configuration database.
SPWebApplication class enables administrators to access IIS properties without opening IIS Manager for example with the help of
IisSettings
and
ApplicationPool
property, we can access the properties of the IIS application pool to which the WSS Web application is assigned.
Sites
property is used to get the collection of site collections within the Web application. It returns SPSiteCollection object which is a collection of SPSite objects.
ContentDatabases
property is used to get the collection of content databases used in the Web application. It return SPContentDatabaseCollection object which is a collection of SPContentDatabase objects.
SPDatabase Object
SPDatabase object encapsulates access to Microsoft SQL Server databases.
Databases
property of the
SPDatabaseServiceInstance
object can be used to get the collection of databases that support the database service instance.
SPContentDatabase Object
SPContentDatabase object represents a content database that contains user data for a SharePoint web application. ContentDatabases property of the SPWebApplication object can be used to get the collection of all the content databases that are used by the Web application. ContentDatabase property of the
SPSite
object can also be used to get the content database for a site collection.
Sites property is used to get the collection of site collections for which the content database stores data.
WebApplication property is used to get the parent Web application.
SPSiteCollection Object
SPSiteCollection
object represents the collection of site collections within the Web application and each site collection is represented by SPSite object.
Object model of Site Architecture:
Following diagram shows the Windows SharePoint Services site architecture in relation to the SharePoint objects and collections. All these objects and collections are available in the “
Microsoft.SharePoint
” namespace.
SPSite Object
SPSite object represents a collection of sites in a Web application, including a top-level Web site and all its sub sites. This collection of sites is known as “Site Collection”. Each site in the site collection, top-level site as well as all its sub sites is represented by a SPWeb object.
Although a SPSite object represents a collection of sites, the SPSite class is not a collection in the sense of a class that implements
ICollection
. A
SPSiteCollection
class implements the latter interface and it represents a collection of SPSite objects.
SPSite object can be instantiated by following methods:
·
SPSite constructor can be used to instantiate a SPSite object for a specific site collection within a console application, or windows application, or on an ASP.NET page
SPSite objSPSite = new SPSite("Absolute_URL");
·
Within an ASP.NET application,
Site
property of the SPContext class can be used to get the SPSite object
that represents the current site collection
SPSite objSPSite = SPContext.Current.Site;
·
Get
SPSiteCollection
object from the
Sites
property of the
SPWebApplication
class. This SPSiteCollection represents the collection of site collections in a SharePoint Web application, so just use an indexer to return a single site collection from the collection.
SPSiteCollection objSiteCollection = objWebApplication.Sites;
int index = 0;
SPSite objSite = objSiteCollection[index];
·
RootWeb property of SPSite class returns its child top-level website. In turn, the SPWeb object that represents the top-level Web site has a Webs property that holds all its immediate child sub sites. The AllWebs property of SPSite returns all the sub sites and the top-level Web site.
SPWeb Object
Each SharePoint website is represented by SPWeb object whether it is a top level website or a sub site. SPWeb object has members that can be used to manage a site, including its template and theme, as well as to access files and folders on the site.
SPWeb object can be a child of another SPWeb object or of a SPSite object. If it is the child of a SPSite object, it is the top-level Web site in its site collection. A hierarchy of Web sites always has exactly one top-level Web site. This site is represented by a SPWeb object which is an immediate child of a SPSite object.
SPWeb object has a
Webs
property that returns a collection of other SPWeb objects; specifically, the immediate child sub sites under it.
The
Lists
property returns a
SPListCollection
object that represents all the lists in the site. Each list in a site is represented by SPList object.
SPWeb object can be instantiated by following methods:
·
To get SPWeb object for top level website following code snippet can be used:
1)
SPSite objSPSite = new SPSite("Absolute_URL");
SPWeb objSPWeb = objSPSite.OpenWeb();
OR
2)
SPSite objSPSite = new SPSite("Absolute_URL");
SPWeb objSPWeb = objSPSite.RootWeb();
·
To get SPWeb object for top level website as well as for each sub site, following code snippet can be used:
SPSite objSPSite = new SPSite("Absolute_URL");
SPWeb objSPWeb = objSPSite.AllWebs[index];
·
To get SPWeb object for each sub site only, following code snippet can be used:
SPSite objSPSite = new SPSite("Absolute_URL");
SPWeb objSPWeb = objSPSite.OpenWeb();
SPWeb objSPWeb = objSPWeb.Webs[index];
SPList Object
Each shared list and document library in a SharePoint website is represented by SPList object.
SPList
object has members that are used to manage the list or access items in the list.
·
GetItems method can be used to perform queries that return specific items.
·
Fields property returns a SPFieldCollection object that represents all the fields, or columns, in the list.
·
Items property returns a SPListItemCollection object that represents all the items, or rows, in the list.
·
Folders property returns the collection of folder items for the list.
·
Lists property can be used to get
the
parent collection of lists to which the list belongs.
·
ParentWeb property can be used to get the parent Web site for the list.
·
Delete method can be used to delete the list.
·
GetChanges method can be used to get from the change log the collection of changes that have occurred in the list.
·
Update method can be used to update the database with changes that are made to the list.
SPField Object
SPField object represents a field in a list.
·
Title property can be used to get or set the display name for the field.
·
Type property can be used to get or set the type of the field.
·
Delete method can be used to delete the field.
·
Update method can be used to update the database with changes that are made t
o the field.
SPListItem Object
SPListItem object represents a single row item in the list.
·
Fields property returns the collection of all fields in the parent list of the SPListItem.
·
Delete method can be used to delete a row from the list.
·
Update method can be used to update a row in the list.
·
Following
code snippet can be used to add a row in the list:
spListItemObject = spListObject.Items.Add();
//assign values for each column of this row
spListItemObject.Update();
Related Articles and Tutorials
New Features in Windows SharePoint Services 3.0
Windows SharePoint Services 3.0 takes full advantage of Microsoft ASP.NET 2.0 and the core Microsoft .NET 2.0 runtime. WSS 3.0 offers a lot of new features...
SharePoint Web Services | List of all Web Services available with WSS 3.0/MOSS 2007
SharePoint application development and customization requires to interact to SharePoint components. SharePoint Web Services enables us to interact with SharePoint server remotely...
SharePoint Glossary
To help you familiarize with the SharePoint vocabulary, we are providing the definion of various terms used in SharePoint...
Features of SharePoint/MOSS 2007
MOSS Stands for “Microsoft Office SharePoint Server”. It is an extension of Windows SharePoint Services (WSS 3.0) that allows all information to be organized...
Concept of Features in SharePoint
One of the major concepts introduced in WSS 3.0/MOSS 2007 is the “Feature”. Feature is a mechanism for deployment which drastically reduces the complexity...
Add comment
Note: Comments will be published only once approved by the moderator.
Name*
E-mail*
(Will show your
Gravatar
icon)
Website
Country
[Not specified]
Afghanistan
Albania
Algeria
Argentina
Armenia
Australia
Austria
Azerbaijan
Bahrain
Bangladesh
Belarus
Belgium
Belize
Bolivia
Bosnia and Herzegovina
Brazil
Brunei Darussalam
Bulgaria
Canada
Caribbean
Chile
Colombia
Costa Rica
Croatia
Czech Republic
Denmark
Dominican Republic
Ecuador
Egypt
El Salvador
Estonia
Faroe Islands
Finland
France
Georgia
Germany
Greece
Guatemala
Honduras
Hong Kong S.A.R.
Hungary
Iceland
India
Indonesia
Iran
Iraq
Ireland
Islamic Republic of Pakistan
Israel
Italy
Jamaica
Japan
Jordan
Kazakhstan
Kenya
Korea
Kuwait
Kyrgyzstan
Latvia
Lebanon
Libya
Liechtenstein
Lithuania
Luxembourg
Macao S.A.R.
Macedonia (FYROM)
Malaysia
Maldives
Malta
Mexico
Mongolia
Morocco
Nepal
Netherlands
New Zealand
Nicaragua
Norway
Oman
Panama
Paraguay
People's Republic of China
Peru
Philippines
Poland
Portugal
Principality of Monaco
Puerto Rico
Qatar
Republic of the Philippines
Romania
Russia
Saudi Arabia
Serbia
Singapore
Slovakia
Slovenia
South Africa
Spain
Sweden
Switzerland
Syria
Taiwan
Thailand
Trinidad and Tobago
Tunisia
Turkey
U.A.E.
Ukraine
United Kingdom
United States
Uruguay
Uzbekistan
Venezuela
Vietnam
Yemen
Zimbabwe
Comment
Preview
Enter the text as shown in image:
Notify me when new comments are added
.net
.net framework
abap
android
apple
asp
asp.net
basis
bios
blackberry
browser
c#
cell phone
cell phones
certifications
cloud computing
computer
concept of features
digital camera
dispose
document library
download file
email
features of sharepoint service pack
fico
fico tcodes
fico transaction codes
gadgets
google
google android
google earth
google ranking
google search
gps
htc
improve performance
internet
internet business
ipad
iphone
iphone 4g
java
java certifications
javascript
keyboard shortcuts
laptop
microsoft outlook
mobile
mobile phone
mobile phones
mobiles
moss
moss 2007
online business
open handset alliance
pda
phone
receiver assembly
rss
saas
sap
sap fico
sap fico transaction codes
sap tcodes
sap transaction codes
search engine
search engine ranking
sem
seo
sharepoint
sharepoint 2007
sharepoint customization
sharepoint features
sharepoint service pack
shortcut keys
smart phone
smart phones
software
software as a service
stsadm
sun
sun certifications
tcodes
technical certifications
transaction code
transaction codes
usb
vb.net
viewstate
visual studio
web marketing
web part
website
website promotion
windows
windows server
windows vista
windows xp
windows7
windows7 gadgets
wss 3.0
Signup for our weekly email newsletter
Submit Content
Submit Tutorials & Articles
Submit Code Snippets
Submit Interview Question
Bookmark & Share
X
Digg
Facebook
Del.icio.us
Reddit
Google
Technorati
Yahoo
Live
Stumble
MySpace
Twitter
MySpace
Articles Categories
Concepts and Definitions
Gadgets
Audio/Video Players
Cameras
Computers/Laptops
Mobiles/PDAs
Other Gadgets
Help and How-To
Internet
Internet-Misllaneous
Online Business
Online Services
SEO
Web Applications
Programming
JavaScript
Microsoft Technologies
.Net Framework
ASP.Net
C#
SharePoint
VB.Net
Visual Studio
SAP
ABAP
Transaction Codes
Software
Microsoft Applications
Mobile Applications
Other Softwares
Windows
Technical Certifications
Sun Java