RestrictToListItem method

SPAuditQuery.RestrictToListItem method

Restricts the query to events that are relevant to the specified list item.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public void RestrictToListItem(
	SPListItem listItem


Type: Microsoft.SharePoint.SPListItem

An SPListItem object that identifies the item whose audit events are included in the query.

If RestrictToListItem is called, you should not call RestrictToList too, because the call to RestrictToListItem already restricts the query to the parent of listItem.

The following example (from Item-Level Auditing with SharePoint Server 2007) shows this method in use.

SPAuditQuery wssQuery = new SPAuditQuery(siteCollection);
SPAuditEntryCollection auditCol = site.Audit.GetEntries(wssQuery);

foreach (SPAuditEntry entry in auditCol) {
  // get info from audit log
© 2016 Microsoft