Export (0) Print
Expand All

SqlSyncStoreMetadataCleanup Class

Sync Framework 2.0

Represents cleanup of change-tracking metadata in a SQL Server database that is synchronized by using a SqlSyncProvider.

Namespace: Microsoft.Synchronization.Data.SqlServer
Assembly: Microsoft.Synchronization.Data.SqlServer (in microsoft.synchronization.data.sqlserver.dll)

public class SqlSyncStoreMetadataCleanup
public class SqlSyncStoreMetadataCleanup
public class SqlSyncStoreMetadataCleanup

Cleanup involves deleting metadata for rows that have been deleted from a base table. Sync Framework uses two kinds of metadata:

  • Table-level metadata that tracks inserts, updates, and deletes for each table that is synchronized.

    There is one row of metadata for each row in the base table. If a row is deleted from the base table and all nodes in all scopes have received it, the metadata row can be safely deleted.

  • Database-level metadata that tracks which changes each node has received from other nodes.

    This metadata is typically stored in one scope table for each node database. Rows in the scope table should never be deleted unless the scope is dropped.

Cleanup is retention-based, which means that metadata that is older than the specified number of days is deleted. For SQL Server databases, use the SqlSyncStoreMetadataCleanup object; and for SQL Server Compact databases, use the SqlCeSyncStoreMetadataCleanup object. For more information, see How to: Clean Up Metadata for Collaborative Synchronization (SQL Server).

The following code example calls PerformCleanup for metadata that is more than 7 days old. To view this code in the context of a complete example, see How to: Clean Up Metadata for Collaborative Synchronization (SQL Server).

SqlSyncStoreMetadataCleanup metadataCleanup = new SqlSyncStoreMetadataCleanup(serverConn);
bool cleanupSuccessful; 
metadataCleanup.RetentionInDays = 7;
cleanupSuccessful = metadataCleanup.PerformCleanup();


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft