Filtering Data for Simple Providers

In some situations, the destination replica requires only a subset of the data that is available at the source replica. For example, a salesperson might require detailed product information only for those products that she sells regularly. Simple providers enable replicas to filter data by implementing a filtering interface. By filtering data, you can do the following:

  • Reduce the amount of data sent over the network.

  • Reduce the amount of storage space that is required on a replica. This is especially important for devices.

  • Provide custom data partitions based on individual replica requirements.

  • Avoid or reduce conflicts because different data partitions can be sent to different replicas.

Be aware that simple providers cannot use custom filters or unexpected results may occur. Custom filters are filters that use the CustomFilterInfo class (for managed code) or ICustomFilterInfo interface (for unmanaged code).

To filter data, use the following interfaces:

Managed Code Example

The following code example uses filter negotiation interfaces to determine whether a specific filter should be used during a synchronization session. Filter negotiation enables a destination provider to specify that the source provider should use one or more filters during change enumeration; the source provider can accept or reject a filter. If a source provider does not support any of the requested filters, the destination provider can choose to receive all the data and do the filtering itself. Sync Framework calls the providers appropriately to negotiate filter usage.

The following code example first specifies a filter option of None. This means that items should be filtered out even if they are already known to the destination. The code example then implements the IsItemInFilterScope(ItemFieldDictionary) method, which filters out items based on one of the item field values. After the filter is defined, the code example implements the UseFilterThisSession method. This enables an application to specify whether filtering should be used on a per-session basis.

Vea también

Conceptos

Implementing a Simple Custom Provider

How to: Create a Managed Simple Provider