Share via


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)

Syntax

'Declaration
Public Sub RestrictToListItem ( _
    listItem As SPListItem _
)
'Usage
Dim instance As SPAuditQuery
Dim listItem As SPListItem

instance.RestrictToListItem(listItem)
public void RestrictToListItem(
    SPListItem listItem
)

Parameters

Remarks

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

Examples

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

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

foreach (SPAuditEntry entry in auditCol) {
  // get info from audit log
}
Dim wssQuery As New SPAuditQuery(siteCollection)
wssQuery.RestrictToListItem(item)
Dim auditCol As SPAuditEntryCollection = site.Audit.GetEntries(wssQuery)

For Each entry As SPAuditEntry In auditCol
  ' get info from audit log
Next entry

See also

Reference

SPAuditQuery class

SPAuditQuery members

Microsoft.SharePoint namespace

Other resources

Item-Level Auditing with SharePoint Server 2007