共用方式為


SimpleSyncProviderDeleteMode 列舉型別

表示是否要將本機項目刪除傳播至其他複寫的選項。

命名空間: Microsoft.Synchronization.SimpleProviders
組件: Microsoft.Synchronization.SimpleProviders (在 microsoft.synchronization.simpleproviders.dll)

語法

'宣告
Public Enumeration SimpleSyncProviderDeleteMode
'用途
Dim instance As SimpleSyncProviderDeleteMode
public enum SimpleSyncProviderDeleteMode
public enum class SimpleSyncProviderDeleteMode
public enum SimpleSyncProviderDeleteMode
public enum SimpleSyncProviderDeleteMode

成員

  成員名稱 描述
LocalOnly 從本機存放區中刪除項目,但是刪除不會傳播至其他複寫。 
Normal 從本機存放區中刪除項目,而且刪除會傳播至其他複寫。 

備註

某些同步處理案例需要能夠刪除本機複寫之某個項目的能力,而不需將該項刪除動作傳播到其他複寫。例如,伺服器可能會與存放不同銷售人員之資訊的幾個裝置同步處理。每一個裝置的空間都有限,因此銷售人員會從裝置中刪除舊的完成訂單。這類刪除動作不應該傳播到伺服器,因為伺服器仍需要此資料。簡單提供者可讓您指定只能在本機刪除資料。若要根據每個工作階段來控制刪除行為,請對 SetDeleteMode 方法指定適當的選項。

範例

下列程式碼範例指定不應該在同步處理期間傳播刪除動作。

public override void EnumerateChanges(byte[] anchor, AnchorEnumerationContext context)
{

    context.SetDeleteMode(SimpleSyncProviderDeleteMode.LocalOnly);
    
    List<LocalItemChange> itemChanges = new List<LocalItemChange>();

    int startIndex = -1;

    if (anchor != null)
    {
        startIndex = _store.Changes.IndexOfKey(BitConverter.ToUInt64(anchor, 0));
    }

    for (int i = startIndex + 1; i < _store.Changes.Count; i++)
    {
        itemChanges.Add(_store.Changes.Values[i]);
    }

    // If the anchor is corrupt or out of date we could revert back to 
    // full enumeration mode for this session, and enumerate all items. 
    // This is done by calling context.ReportItemsAndAutodetectDeletes.
    context.ReportChanges(itemChanges, _store.GetAnchor());
}
public override void EnumerateChanges(byte[] anchor, AnchorEnumerationContext context) 
{ 

context.SetDeleteMode(SimpleSyncProviderDeleteMode.LocalOnly); 

List<LocalItemChange> itemChanges = new List<LocalItemChange>(); 

int startIndex = -1; 

if (anchor != null) 
{ 
startIndex = _store.Changes.IndexOfKey(BitConverter.ToUInt64(anchor, 0)); 
} 

for (int i = startIndex + 1; i < _store.Changes.Count; i++) 
{ 
itemChanges.Add(_store.Changes.Values[i]); 
} 

// If the anchor is corrupt or out of date we could revert back to 
// full enumeration mode for this session, and enumerate all items. 
// This is done by calling context.ReportItemsAndAutodetectDeletes. 
context.ReportChanges(itemChanges, _store.GetAnchor()); 
} 

請參閱

參考

Microsoft.Synchronization.SimpleProviders 命名空間