Partilhar via


SPChangeCollection.IncludesBeginning Property

Gets a value that indicates whether the collection includes changes taken from the beginning of the content database's change log.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public ReadOnly Property IncludesBeginning As Boolean
    Get
'Usage
Dim instance As SPChangeCollection
Dim value As Boolean

value = instance.IncludesBeginning
public bool IncludesBeginning { get; }

Property Value

Type: System.Boolean
true if the collection includes the beginning of the content database's change log; otherwise, false.

Remarks

This property will have a value of true only for collections obtained within the SPChangeCollection.CollectionScope.ContentDB scope. In other words, to get changes at the beginning from the content database’s change log, you must call the GetChanges() method of the SPContentDatabase class.

Examples

The following example is a console application that retrieves successive change collections from the content database change log. As each collection is obtained, the application prints the value of the IncludesBeginning property to the console.

using System;
using Microsoft.SharePoint;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite siteCollection = new SPSite("https://localhost"))
         {
            long total = 0;
            SPChangeToken token = null;

            // Get the first batch of changes.
            SPChangeCollection changes = siteCollection.ContentDatabase.GetChanges(token);
            // Loop until the end of the log is reached.
            while (changes.Count > 0)
            {
               total += changes.Count;

               Console.WriteLine(changes.IncludesBeginning);

               // Go get another batch.
               token = changes.LastChangeToken;
               changes = siteCollection.ContentDatabase.GetChanges(token);
            }

            Console.WriteLine("{0:#,#} changes", total);
         }
         Console.Write("\nPress ENTER to continue...");
         Console.ReadLine();
      }
   }
}
Imports System
Imports Microsoft.SharePoint

Module ConsoleApp
   Sub Main()
      Using siteCollection As SPSite = New SPSite("https://localhost")

         Dim total As Long = 0
         Dim token As SPChangeToken = Nothing

         ' Get the first batch of changes.
         Dim changes As SPChangeCollection = siteCollection.ContentDatabase.GetChanges(token)

         ' Loop until the end of the log is reached.
         While changes.Count > 0

            total += changes.Count

            Console.WriteLine(changes.IncludesBeginning)

            ' Go get another batch.
            token = changes.LastChangeToken
            changes = siteCollection.ContentDatabase.GetChanges(token)

         End While

         Console.WriteLine("{0:#,#} changes", total)

      End Using

      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()

   End Sub
End Module

The following output is printed to the console when the application is run against a very modest installation of SharePoint Foundation.

True
False
False
2,301 changes

Press ENTER to continue...

See Also

Reference

SPChangeCollection Class

SPChangeCollection Members

Microsoft.SharePoint Namespace

Other Resources

Using the Change Log