0

I am trying to provision a few scopes on the same table to synchronize different sets of the data within the table. The provisioning works great with no errors. When I go to synchronize, however, the call to SyncOrchestrator.Synchronize() times out.

When I sync just one of the scopes, it appears that all of the data is being synchronized, not just the data being defined by the scope filter.

Here is my provisioning code for a one of the scopes. The scopes are each run in a separate thread so that they are synchronized concurrently.

Server Provisioning:

var remoteLogVariableScopeDescription = new DbSyncScopeDescription(string.Format("{0}_{1}", DatabaseID, scopeName));
remoteLogVariableScopeDescription.Tables.Add(SqlCeSyncDescriptionBuilder.GetDescriptionForTable("TableName", localConnection));
var remoteDatabaseConfiguration = new SqlSyncScopeProvisioning(remoteConnection, remoteLogVariableScopeDescription);
remoteDatabaseConfiguration.ObjectPrefix = string.Format("Sync_{0}", scopeName);
remoteDatabaseConfiguration.Tables["TableName"].AddFilterColumn("Time);
remoteDatabaseConfiguration.Tables["TableName"].FilterClause = [side].Time >= DATEADD(minute, -1, GETDATE());
remoteDatabaseConfiguration.SetCreateTableDefault(DbSyncCreationOption.Skip);
remoteDatabaseConfiguration.SetUseBulkProceduresDefault(true);
remoteDatabaseConfiguration.CommandTimeout = 30;
remoteDatabaseConfiguration.Apply()

Local Provisioning:

DbSyncScopeDescription localFrequentScopeDescription = SqlSyncDescriptionBuilder.GetDescriptionForScope(string.Format("{0}_{1}", DatabaseID, scopeName), string.Format("Sync_{0}", scopeName), remoteConnection);
var localDatabaseConfiguration = new SqlCeSyncScopeProvisioning(localConnection, localFrequentScopeDescription);
localDatabaseConfiguration.ObjectPrefix = string.Format("Sync_{0}", scopeName);
localDatabaseConfiguration.SetCreateTableDefault(DbSyncCreationOption.Skip);
localDatabaseConfiguration.Apply();

My questions are: Is the scope filter I provided possible? Can you run multiple scopes on the same table concurrently?

Thanks in advance for any help!

Stuart
  • 801
  • 1
  • 9
  • 18

2 Answers2

1

Filters are not supported on SQL Sever Compact Edition. Any changes that you make there will be synced back to the server.

Scott Munro
  • 13,369
  • 3
  • 74
  • 80
1

as Scott mentioned, the SqlCeSyncProvider doesnt support filtering.

likewise, even if you change the client to SQL Express/Server, GetDescriptionForScope does not include the filter configuration when returning the scope configuration.

also, you can define multiple against the same scope, however beware of overlapping scopes where rows may belong to multiple scopes. that may result to sync loops.

e.g. (assuming bidirectional sync)

scope 1 filter includes row 1

scope 2 filter also includes row 1

you update row 1 on server

scope 1 syncs and applies row 1 to your client

scope 2 syncs and detects the row 1 downloaded and applied by scope 1 (scope 2 has no idea of scope1)

so scope 2 uploads and applies row 1 to server (the same row change in server returned to the server)

scope 1 syncs and picks up row 1 from server again and so on...

JuneT
  • 7,840
  • 2
  • 15
  • 14
  • Thanks for the clarification. I marked Scotts answer as correct since it came in first. That information is useful to know, though. I think I ended up reading somewhere that SQL CE doesn't support multiple scopes on the same table. When I tried this, the sync would eventually finish, but it would always throw an exception and lock the table. – Stuart Jul 30 '12 at 14:59
  • 1
    SQL CE supports multiple scopes against the same table. its concurrent sync that throws the error and you will get it regardless of whether you have one or more scopes. its a locking problem. – JuneT Jul 31 '12 at 00:02
  • Is that the case with different scopes on different tables as well? I've had two scopes running on different tables without too much of a problem. – Stuart Jul 31 '12 at 16:36