DbSyncAdapter::SelectMetadataForCleanupCommand Property

Gets or sets the query or stored procedure that is used to cleanup rows in metadata tables.

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

public:
property IDbCommand^ SelectMetadataForCleanupCommand {
	IDbCommand^ get ();
	void set (IDbCommand^ value);
}

Property Value

Type: System.Data::IDbCommand
An IDbCommand object that contains a query or stored procedure.

Synchronization adapter commands enable you to specify the queries and stored procedures that are used to select from and apply data and metadata changes to a peer database. For more information, see How to: Provision a Server Database for Collaborative Synchronization (Non-SQL Server). Each command uses session variables that enable you to pass values during synchronization. These variables are specified like other parameters to queries or stored procedures in ADO.NET commands. For more information, see How to: Use Session Variables for Collaborative Synchronization (Non-SQL Server).

The following code example creates a command that deletes rows from the Customer_Tracking table at a peer. Rows are typically deleted after a period of time if they relate to rows that have been deleted from the base table. The command is a stored procedure that is defined in Setup Scripts for Database Provider How-to Topics. To view this code in the context of a complete example, see How to: Clean Up Metadata for Collaborative Synchronization (Non-SQL Server).

SqlCommand selMetadataCustomerCmd = new SqlCommand();
selMetadataCustomerCmd.CommandType = CommandType.StoredProcedure;
selMetadataCustomerCmd.CommandText = "Sync.sp_Customer_SelectMetadata";
selMetadataCustomerCmd.Parameters.Add("@metadata_aging_in_hours", SqlDbType.Int).Value = MetadataAgingInHours;
selMetadataCustomerCmd.Parameters.Add("@sync_scope_local_id", SqlDbType.Int);

adapterCustomer.SelectMetadataForCleanupCommand = selMetadataCustomerCmd;


Dim selMetadataCustomerCmd As New SqlCommand()

        With selMetadataCustomerCmd
            .CommandType = CommandType.StoredProcedure
            .CommandText = "Sync.sp_Customer_SelectMetadata"
            .Parameters.Add("@metadata_aging_in_hours", SqlDbType.Int).Value = MetadataAgingInHours
            .Parameters.Add("@sync_scope_local_id", SqlDbType.Int)
        End With

        adapterCustomer.SelectMetadataForCleanupCommand = selMetadataCustomerCmd


Show: