SPChange class
Represents a change that has been made to a SharePoint object within the scope of an item, list, Web site, site collection, or content database, or to a security policy within the scope of a Web application.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Each entry in the SharePoint Foundation change log is represented by a subclass of the SPChange class. The properties of the parent SPChange class contain basic information about a change, including the type of change, as represented by the ChangeType property; the time of the change, as represented by the Time property; and the ID of the site collection where the change was made, as represented by the SiteId property.
The properties of subclasses of SPChange contain information specific to the type of object that was changed. For example, the SPChangeItem class represents a change to an SPListItem object and therefore has a ListId property that identifies the list where the item was changed. Similarly, the SPChangeList class represents a change to a list and has a WebId property that identifies the Web site where the list was changed.
The change log does not record changes to all SharePoint objects, only to selected object types. The object types that are tracked in the change log are listed in the following table, along with the subclasses of SPChange that represent changes to them.
Subclass | Represents changes to |
|---|---|
SPAlert objects. | |
SPContentType objects. | |
SPField objects. | |
SPFile objects that exist outside of a list and do not have corresponding items. | |
SPFolder objects that exist outside of a list and do not have corresponding items. | |
SPGroup objects. | |
SPListItem objects and files and folders that might be associated with them. | |
SPList objects. | |
SPPolicy objects. | |
SPSite objects. | |
SPUser objects. | |
SPView objects. | |
SPWeb objects. |
Use the GetChanges method of the SPList, SPWeb, SPSite, or SPContentDatabase object to return a SPChangeCollection object with the changes that have occurred within a given scope. You can then enumerate the collection and examine each of its members individually.
The total number of changes returned by a query against the change log could be very large, depending on the retention period set for the log and the scope of the query. For performance reasons, changes are returned in batches of limited size. If you want all changes rather than only the first batch, your code should call the GetChanges method in a loop until it returns a collection with zero changes, signifying that it has reached the end of the log. You can use the ChangeToken from the last change of the first batch to get the second batch, and so on until you get an empty collection.
Alternatively, you can pass an SPChangeQuery object to the GetChanges method. This object has properties that you can use to filter changes by object type and by change type. You can also adjust the size of the collection that is returned on a single roundtrip by setting the SPChangeQuery object’s FetchLimit property.
For more information about working with the change log, see Using the Change Log.
Microsoft.SharePoint.SPChange
Microsoft.SharePoint.SPChangeAlert
Microsoft.SharePoint.SPChangeContentType
Microsoft.SharePoint.SPChangeField
Microsoft.SharePoint.SPChangeFile
Microsoft.SharePoint.SPChangeFolder
Microsoft.SharePoint.SPChangeGroup
Microsoft.SharePoint.SPChangeItem
Microsoft.SharePoint.SPChangeList
Microsoft.SharePoint.SPChangeSecurityPolicy
Microsoft.SharePoint.SPChangeSite
Microsoft.SharePoint.SPChangeUser
Microsoft.SharePoint.SPChangeView
Microsoft.SharePoint.SPChangeWeb