DbSyncProvider::CleanupMetadata Method

Removes change tracking metadata from the database and updates the cleanup knowledge to reflect the point where the cleanup process stopped. This enables outdated nodes to be identified.

Namespace:  Microsoft.Synchronization.Data
Assembly:  Microsoft.Synchronization.Data (in Microsoft.Synchronization.Data.dll)

public:
virtual bool CleanupMetadata()

Return Value

Type: System::Boolean
true if metadata cleanup ran successfully; otherwise false.

ExceptionCondition
ObjectDisposedException

This DbSyncProvider is disposed.

The following code example calls the CleanupMetadata method. The code instantiates a provider and calls the ConfigureDbSyncProvider method in the SampleSyncProvider class. All the required DbSyncAdapter and DbSyncProvider properties are defined in this class. This includes the SelectMetadataForCleanupCommand property. The value of 7 that is passed to the ConfigureDbSyncProvider method is the metadata retention period in days.

sampleSyncProvider = new SampleSyncProvider();
DbSyncProvider provider1 = sampleSyncProvider.ConfigureDbSyncProvider(Utility.ConnStr_DbSync1, 7);

if (provider1.CleanupMetadata() == true)
{
    Console.WriteLine(String.Empty);
    Console.WriteLine("Metadata cleanup ran in the SyncSamplesDb_Peer1 database.");
    Console.WriteLine("Metadata more than 7 days old was deleted.");
}
else
{
    Console.WriteLine("Metadata cleanup failed, most likely due to concurrency issues.");
}


sampleSyncProvider = New SampleSyncProvider()
Dim provider1 As DbSyncProvider = sampleSyncProvider.ConfigureDbSyncProvider(Utility.ConnStr_DbSync1, 7)

If provider1.CleanupMetadata() = True Then
    Console.WriteLine([String].Empty)
    Console.WriteLine("Metadata cleanup ran in the SyncSamplesDb_Peer1 database.")
    Console.WriteLine("Metadata more than 7 days old was deleted.")
Else
    Console.WriteLine("Metadata cleanup failed, most likely due to concurrency issues.")
End If


Show: