Server Object Model in SharePoint 2013
What is Object Model ?
An object model is group of objects related to each other using Has-a Relationship.
Let us See the below figure. You will get Clear idea on SharePoint Farm.
Open visual studio 2012-->File-->New-->Select Console Application Template(Select Visual C# on Left Side)-->give Proper Name Click on Ok.
Go to Build-->Configuration Manager-->select X64 at Activation Solution platform.
One more Important Point Here You want to add reference--> Microsoft.sharePoint.dll
Once Coding part Over, Build the Project and You will get the following Output.
An object model is group of objects related to each other using Has-a Relationship.
Let us See the below figure. You will get Clear idea on SharePoint Farm.
Open visual studio 2012-->File-->New-->Select Console Application Template(Select Visual C# on Left Side)-->give Proper Name Click on Ok.
Go to Build-->Configuration Manager-->select X64 at Activation Solution platform.
One more Important Point Here You want to add reference--> Microsoft.sharePoint.dll
Get All Web Applications in a Farm:
Add Name Spaces:
Using MicroSoft.SharePoint;
Using MicroSoft.SharePoint.Administration
SPFarm farm = SPFarm.Local;
foreach (SPService service in farm.Services)
{
if (service is SPWebService)
{
SPWebService webservice = service as SPWebService;
foreach (SPWebApplication webapp in webservice.WebApplications)
{
Console.WriteLine(webapp.DisplayName);
}
}
}
foreach (SPService service in farm.Services)
{
if (service is SPWebService)
{
SPWebService webservice = service as SPWebService;
foreach (SPWebApplication webapp in webservice.WebApplications)
{
Console.WriteLine(webapp.DisplayName);
}
}
}
You can Find the below Figure:
Once Coding part Over, Build the Project and You will get the following Output.
Thanks for visiting My Blog...

.png)
Comments
Post a Comment