Share via


AnchorEnumerationContext.SetDeleteMode Method

Sets whether a delete is a normal delete that is propagated to other replicas, or a local-only delete.

Namespace: Microsoft.Synchronization.SimpleProviders
Assembly: Microsoft.Synchronization.SimpleProviders (in microsoft.synchronization.simpleproviders.dll)

Syntax

'Declaration
Public Overrides Sub SetDeleteMode ( _
    deleteMode As SimpleSyncProviderDeleteMode _
)
'Usage
Dim instance As AnchorEnumerationContext
Dim deleteMode As SimpleSyncProviderDeleteMode

instance.SetDeleteMode(deleteMode)
public override void SetDeleteMode (
    SimpleSyncProviderDeleteMode deleteMode
)
public:
virtual void SetDeleteMode (
    SimpleSyncProviderDeleteMode deleteMode
) override
public void SetDeleteMode (
    SimpleSyncProviderDeleteMode deleteMode
)
public override function SetDeleteMode (
    deleteMode : SimpleSyncProviderDeleteMode
)

Parameters

  • deleteMode
    A SimpleSyncProviderDeleteMode enumeration value that specifies whether a delete is a normal delete that is propagated to other replicas, or a local-only delete.

Remarks

Some synchronization scenarios require the ability to delete an item at a local replica without propagating that delete to other replicas. For example, a server might synchronize with several devices that store information for different salespeople. Each device has limited space, so salespeople delete old completed orders from the device. These kinds of deletes should not be propagated to the server, because the server still requires this data. Simple providers let you specify that the data should only be deleted locally. To control the behavior of deletes on a per-session basis, specify the appropriate option by using this method.

Example

The following code example specifies that deletes should not be propagated during synchronization.

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()); 
} 

See Also

Reference

AnchorEnumerationContext Class
AnchorEnumerationContext Members
Microsoft.Synchronization.SimpleProviders Namespace