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


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);
                    }
                }
            }


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...

Comments

Popular posts from this blog

Search Service Application Error in SP2013

Errors While Importing Site Collection in SharePoint 2013/2010

Deleting Multiple Sub-sites within Site using PowerShell