Thanks Phil for you response.
I am aware that the tables are processed in the other in which they are added to the SyncAdpters collection, however, it isn't reversing the order for deleted rows.
Here is what I have.
On the client side, I have a custom SyncProvider that inherits from the "
SqlExpressClientSyncProvider" class. In the constructor of this provider, I have the following.
// Initialize the Client table SyncAdapter.
SyncAdapter clientSyncAdapter = new SyncAdapter( Db.Tables.Client );
this.SyncAdapters.Add( clientSyncAdapter );
clientSyncAdapter.SelectIncrementalInsertsCommand = this.GetStoredProcCommand( Db.Sprocs.ClientSelectIncrementalInserts, database, connection );
clientSyncAdapter.SelectIncrementalUpdatesCommand = this.GetStoredProcCommand( Db.Sprocs.ClientSelectIncrementalUpdates, database, connection );
clientSyncAdapter.SelectIncrementalDeletesCommand = this.GetStoredProcCommand( Db.Sprocs.ClientSelectIncrementalDeletes, database, connection );
clientSyncAdapter.InsertCommand = this.GetStoredProcCommand( Db.Sprocs.ClientInsert, database, connection );
clientSyncAdapter.UpdateCommand = this.GetStoredProcCommand( Db.Sprocs.ClientUpdate, database, connection );
clientSyncAdapter.DeleteCommand = this.GetStoredProcCommand( Db.Sprocs.ClientDelete, database, connection );
clientSyncAdapter.SelectConflictUpdatedRowsCommand = this.GetStoredProcCommand( Db.Sprocs.ClientSelectConflictUpdatedRows, database, connection );
clientSyncAdapter.SelectConflictDeletedRowsCommand = this.GetStoredProcCommand( Db.Sprocs.ClientSelectConflictDeletedRows, database, connection );
// Initialize the Project table SyncAdapter.
SyncAdapter projectSyncAdapter = new SyncAdapter( Db.Tables.Project );
this.SyncAdapters.Add( projectSyncAdapter );
projectSyncAdapter.SelectIncrementalInsertsCommand = this.GetStoredProcCommand( Db.Sprocs.ProjectSelectIncrementalInserts, database, connection );
projectSyncAdapter.SelectIncrementalUpdatesCommand = this.GetStoredProcCommand( Db.Sprocs.ProjectSelectIncrementalUpdates, database, connection );
projectSyncAdapter.SelectIncrementalDeletesCommand = this.GetStoredProcCommand( Db.Sprocs.ProjectSelectIncrementalDeletes, database, connection );
projectSyncAdapter.InsertCommand = this.GetStoredProcCommand( Db.Sprocs.ProjectInsert, database, connection );
projectSyncAdapter.UpdateCommand = this.GetStoredProcCommand( Db.Sprocs.ProjectUpdate, database, connection );
projectSyncAdapter.DeleteCommand = this.GetStoredProcCommand( Db.Sprocs.ProjectDelete, database, connection );
projectSyncAdapter.SelectConflictUpdatedRowsCommand = this.GetStoredProcCommand( Db.Sprocs.ProjectSelectConflictUpdatedRows, database, connection );
projectSyncAdapter.SelectConflictDeletedRowsCommand = this.GetStoredProcCommand( Db.Sprocs.ProjectSelectConflictDeletedRows, database, connection );
GetStoredProcCommand - is a simple method that returns a DbCommand object that has been initialized for the specified stored procedure.
The "Client" table is the parent table and the "Project" table is the child table. (i.e. the Project table has a ClientId FK column)
On the server side, I have a custom SyncProvider that inherits from the "
DbServerSyncProvider" class. The constructor for this provider has the same initialization code that is listed above.
I have a custom "
SyncAgent" class that contains the following code in the constructor:
// Add the SyncTables that will be included in the synchronization process.
this.AddSyncTable( Db.Tables.Client, TableCreationOption.UseExistingTableOrFail, SyncDirection.Bidirectional, null );
this.AddSyncTable( Db.Tables.Project, TableCreationOption.UseExistingTableOrFail, SyncDirection.Bidirectional, null );
I then call the SyncAgent.Synchronize() method to being the synchronization process. I have debugged the synchronization process and the Client's deleted rows are processed before the Project's deleted rows.
Can you please tell what is missing?
Thanks for your help.
Garry