- SP Farm
- SP Service
- SP Web Application
- SP Content Database
- SP Site
- SP Web
- SP List
- SP List Item
- SP Field
http://msdn.microsoft.com/en-us/library/office/cc768619(v=office.14).aspx
SPFarm
The SPFarm object is the top node in the extensible configuration object model, which is designed to interact with the configuration data store. It contains global settings for all the servers, services, and solutions that are installed in a server farm. Use the Servers, Services, or Solutions property to retrieve these collections.
To access the current server farm object, you can use members on SPFarm.Local. For example, to return an SPServiceCollection object that represents the collection of services in the current server farm, use SPFarm.Local.Services. In addition, you can use the Farm property of classes that derive from the SPPersistedObject class, or you can use the Farm property of the SPSolution class, to get the server farm of the current object or solution.
SPService
To return the parent service of a service instance, use the Service property of the SPServiceInstance class. Use the Services property of the SPFarm class to return an SPServiceCollection object that represents the collection of services on the server farm. Use an indexer to return a single service from the collection using the GUID that identifies the service. For example, if the collection is assigned to a variable named myServices, use myServices[index] in C#, or myServices(index) in Visual Basic, where index is the GUID that identifies the service.To retrieve a single service from the collection by name, use the GetValue method. For example, if the collection is assigned to a variable named myServices, use myServices.GetValue
SPWebApplication
All servers that run the parent Web service (SPWebService) of the Web application must have a provisioned instance of the application. All instances of the application must be configured identically.
Various objects in the Microsoft.SharePoint.Administration namespace provide a WebApplication property through which you can access the containing Web application. Use the WebApplication property of the SPSite class to get the Web application that contains a site collection. To get the Web application of the current HTTP context, you can use SPContext.Current.Site.WebApplication.
Use the WebApplications property of the SPWebService class to return an SPWebApplicationCollection object that represents the collection of Web applications within a Web service. Use an indexer to return a single Web application from the collection. For example, if the collection is assigned to a variable named myWebApplications, use myWebApplications[index] in C#, or myWebApplications(index) in Visual Basic, where index is either the name or the GUID that identifies the Web application.
SPContent Database
Use the ContentDatabase() property of the SPSite class or of the SPWorkItemCollection class to return the content database for a site collection or work item collection. Use the ContentDatabases property of the SPWebApplication class to return the collection of content databases that are used by the Web application.
Use an indexer to return a single content database from a collection of content databases. For example, if the collection is assigned to a variable named myContentDatabases, use myContentDatabases[index] in C#, or myContentDatabases(index) in Visual Basic, where index is either the index number of the field in the collection or the GUID for the content database.
SPSite
To instantiate an SPSite object for a specific site collection on an ASP.NET page, or for a specific site collection within a console application.
Within an ASP.NET application, you can use the Site property of the SPContext class to return an SPSite object that represents the current site collection.
Use the Sites property of the SPWebApplication class to return an SPSiteCollection object that represents the collection of site collections in a SharePoint Web application. Use an indexer to return a single site collection from the collection. For example, if the collection of site collections is assigned to a variable named oSiteCollections, use oSiteCollections[index] in C#, or oSiteCollections(index) in Visual Basic, where index is either the display name or the index number of the site collection in the collection.
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. If you create your own SPSite object, you can use the Dispose method to close the object. You can also instead implement a using statement so that the .NET Framework common language runtime (CLR) automatically releases the memory that is used to store the site collection.
However, if you have a reference to a shared resource, such as when the object is provided by the GetContextSite method in a Web Part, do not use either method to close the object. Using either method on a shared resource causes an Access Violation error to occur. In scenarios where you have a reference to a shared resource, instead let Microsoft SharePoint Foundation or your portal application manage the object.
SPWeb
Many methods and properties in the Microsoft.SharePoint namespace can return a single website. You can use the Webs property of the SPWeb class to return all the immediate child websites beneath a website, excluding children of those child websites. You can also use the AllWebs property of the SPSite class to return all websites within the site collection; or use the GetSubwebsForCurrentUser method of SPWeb to return all websites for the current user.
Use an indexer to return a single website from the collection. For example, if the collection is assigned to a variable named collWebSites, use collWebSites[index] in C#, or collWebSites(index) in Visual Basic, where index is the index number of the site in the collection, the display name of the website, or the GUID for the site.
SPList
A list consists of items or rows, and columns or fields, that contain data. The Items property returns the collection of items in the list, and the Fields property returns the collection of fields in the list. To improve performance, it is best practice to use one of the GetItem* methods to return a filtered collection of items from the list.
Various SPList properties, ParentList properties, and other properties or methods for classes in the Microsoft.SharePoint namespace return a list or collection of lists from a specific context. Otherwise, use the Lists property of either the SPWeb or SPList class to return an SPListCollection object that represents either the collection of lists in a site or the collection of parent lists for a list. Use an indexer to return a single list from the collection. For example, if the collection is assigned to a variable named collLists, use collLists[index] in C#, or collLists(index) in Visual Basic, where index is the index number of the list in the collection, the display name of the list, or the GUID of the list.
SPListItem
You can use an indexer to return a single item from a list item collection. For example, if the collection is assigned to a variable named collListItems, use collListItems[index] in Microsoft C#, or collListItems(index) in Microsoft Visual Basic, where index is the index number of the item in the collection, or the internal name or display name of a list field. For an indexer based on a name, Microsoft SharePoint Foundation first looks for the field by internal name and then by display name.
SPField
Use the Fields property of either the SPList class or the SPListItem class to return an SPFieldCollection object that represents the collection of fields for a list or list item. Use an indexer to return a single field from this collection. For example, if the collection is assigned to a variable named collFields, use collFields[index] in C#, or collFields(index) in Microsoft Visual Basic, where index is either the index number of the field in the collection or the display name of the field.
If you set properties of the SPField class and its inheriting classes, you must call the Update method for changes to take effect in the database.