Share via


SqlSyncStoreMetadataCleanup Class

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

Inheritance Hierarchy

System.Object
  Microsoft.Synchronization.Data.SqlServer.SqlSyncStoreMetadataCleanup

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

Syntax

'Declaration
Public Class SqlSyncStoreMetadataCleanup
'Usage
Dim instance As SqlSyncStoreMetadataCleanup
public class SqlSyncStoreMetadataCleanup
public ref class SqlSyncStoreMetadataCleanup
type SqlSyncStoreMetadataCleanup =  class end
public class SqlSyncStoreMetadataCleanup

The SqlSyncStoreMetadataCleanup type exposes the following members.

Constructors

  Name Description
Public method SqlSyncStoreMetadataCleanup(SqlConnection) Initializes a new instance of the SqlSyncStoreMetadataCleanup class with the specified connection.
Public method SqlSyncStoreMetadataCleanup(SqlConnection, String) Initializes a new instance of the SqlSyncStoreMetadataCleanup class with the specified connection and object prefix.
Public method SqlSyncStoreMetadataCleanup(SqlConnection, String, String) Initializes a new instance of the SqlSyncStoreMetadataCleanup class with the specified connection, object prefix, and object schema.
Public method SqlSyncStoreMetadataCleanup(SqlConnection, String, String, Int32) Initializes a new instance of the SqlSyncStoreMetadataCleanup class with the specified connection, object prefix, object schema, and metadata retention period.

Top

Properties

  Name Description
Public property CommandTimeout Gets or sets the wait time, in seconds, before a metadata cleanup command is stopped and an error is generated.
Public property Connection Gets or sets a SqlConnection object that contains a connection to the database.
Public property ObjectPrefix Gets or sets the optional prefix that is used to identify objects that Sync Framework creates.
Public property ObjectSchema Gets or sets the database schema in which Sync Framework creates objects.
Public property RetentionInDays Gets or sets how old change-tracking metadata must be, in days, for that metadata to be deleted when PerformCleanup is called.

Top

Methods

  Name Description
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method PerformCleanup Removes change-tracking metadata for all scopes from the database and updates the cleanup knowledge to reflect the point where the cleanup process stopped.
Public method ToString (Inherited from Object.)

Top

Remarks

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).

Examples

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();
Dim metadataCleanup As New SqlSyncStoreMetadataCleanup(serverConn)
Dim cleanupSuccessful As Boolean
metadataCleanup.RetentionInDays = 7
cleanupSuccessful = metadataCleanup.PerformCleanup()

Thread Safety

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

See Also

Reference

Microsoft.Synchronization.Data.SqlServer Namespace