DbSyncProvider.CleanupMetadata 方法
從資料庫中移除變更追蹤中繼資料並更新清除知識,以便反映清除處理序停止的時間點。這可讓您識別過期的節點。
此方法與 CLS 不相容。
命名空間: Microsoft.Synchronization.Data
組件: Microsoft.Synchronization.Data (在 microsoft.synchronization.data.dll)
語法
'宣告
<SuppressMessageAttribute("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters")> _
Public Overridable Function CleanupMetadata As Boolean
'用途
Dim instance As DbSyncProvider
Dim returnValue As Boolean
returnValue = instance.CleanupMetadata
[SuppressMessageAttribute("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters")]
public virtual bool CleanupMetadata ()
[SuppressMessageAttribute(L"Microsoft.Globalization", L"CA1303:DoNotPassLiteralsAsLocalizedParameters")]
public:
virtual bool CleanupMetadata ()
/** @attribute SuppressMessageAttribute("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters") */
public boolean CleanupMetadata ()
SuppressMessageAttribute("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters")
public function CleanupMetadata () : boolean
傳回值
如果成功執行了中繼資料清除,則為 true,否則為 false。
範例
下列程式碼範例會呼叫 CleanupMetadata 方法。此程式碼會具現化提供者,並呼叫 SampleSyncProvider
類別中的 ConfigureDbSyncProvider
方法。所有需要的 DbSyncAdapter 和 DbSyncProvider 屬性都在此類別中定義。其中包括 SelectMetadataForCleanupCommand 屬性。傳遞給 ConfigureDbSyncProvider
方法的值 7
是中繼資料保留期 (以天為單位)。
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
請參閱
參考
DbSyncProvider 類別
DbSyncProvider 成員
Microsoft.Synchronization.Data 命名空間