Creating different filters for different clients
-
Thursday, July 09, 2009 9:48 AMHi
I am trying to Sync between central data server with 3 clients and I want each clinet to see specific data based upon the filter as required.Is there any way to do this in the Sync Framework.
Thanks in Advance
Archan- Moved by Max Wang_Chinasoft Thursday, April 21, 2011 12:24 AM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
All Replies
-
Monday, July 13, 2009 7:04 PMModerator
Yes, in the Sync Framework 1.0 you can use Row filtering to only sync items you want to. The source provider should understand the destination's filter, so it can correctly only enumerate items that qualify the destination filter.
However, do note the the replica knowledge size will grow proportional to the number of items in the filter.
With the Sync Framework 2.0 CTP2, you can use custom filters, which have compact knowledge representation, and allow the providers to track move-outs/ins of items from the filter.- Proposed As Answer by Adrian Mustea - MSFTMicrosoft Employee Thursday, July 16, 2009 9:31 PM
-
Wednesday, July 29, 2009 8:07 AMCan you please provide me with some code example of differnt clients using different filter parameters to get the data from the central server.....
Thank
Archan -
Thursday, August 06, 2009 1:19 PM
I have used SYNC fine, and now I used filter passing from client to server
ok, guys I fiex issue, I used TombstoneFilterClause also, but I think it's redundant since I dont have Tombstone tables, I use SQL Server tracking.on server I haveSqlParameter filterParameter = new SqlParameter("@Institution_ID", SqlDbType.UniqueIdentifier);string customerFilterClause = "Institution_ID=@Institution_ID";customerBuilder.FilterClause = customerFilterClause;customerBuilder.FilterParameters.Add(filterParameter);and on client I have :internal class PhotoSyncAgent : SyncAgent{public PhotoSyncAgent(){this.LocalProvider = new PhotoClientSyncProvider();ServiceReference.PhotoServiceClient serviceProxy = new ServiceReference.PhotoServiceClient();this.RemoteProvider = new ServerSyncProviderProxy(serviceProxy);SyncTable depsSyncTable = new SyncTable("department");depsSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;depsSyncTable.SyncDirection = SyncDirection.DownloadOnly;this.Configuration.SyncTables.Add(depsSyncTable);this.Configuration.SyncParameters.Add(new SyncParameter("@Institution_ID", new Guid("248a1343-decb-45a5-906f-2fa4d17f8d76")));}getting such exception: {"Cannot enumerate changes at the DbServerSyncProvider for table 'department' in synchronization group 'department'."}PS. I use SQL Server Change Tracking System, Institution_ID - is FK to institution tableany ideas?
C# developerNow here's another issue when I have data already in server table I try to sync with client table, I get all of the rows from there. so filtering doesnt work.but it works after that first sync. so if I add new records to database, it will be synced afterwards.Question. How should I setup my local database in order to filter values not depending on time created?pS. for now I see only a way, to supply a copy of database to end user aldready syncronized with server when server DB was empty. in this case I wont receive redundant data. but It can give me some troubles in future when we will try to change database(in case of new versions).
C# developer -
Tuesday, September 01, 2009 7:04 AMThank you a lot..
Sorry for late reply...
I think you have implemented N-tier Synchronization.
Can you please let me know as a backend you have used SQL CE or SQL Express ?
If SQL Express can you please prive ne with some code-block as I am also trying to do the same... -
Sunday, September 27, 2009 9:09 AM
Hello. I use SQL express and on client side SQL CE.Here's some sample:on Server:public class: PhotoServerSyncProvider : DbServerSyncProvider{public PhotoServerSyncProvider(){SqlSyncAdapterBuilder newsBuilder = new SqlSyncAdapterBuilder(serverConn);newsBuilder.TableName = "dbo.documentationCategory";newsBuilder.ChangeTrackingType = ChangeTrackingType.SqlServerChangeTracking;newsBuilder.SyncDirection = SyncDirection.Bidirectional;SqlParameter filterParameter = new SqlParameter("@Institution_ID", SqlDbType.UniqueIdentifier);string pictureFilterClause = "Institution_ID=@Institution_ID";newsBuilder.FilterClause = pictureFilterClause;newsBuilder.FilterParameters.Add(filterParameter);SyncAdapter newsSyncAdapter = newsBuilder.ToSyncAdapter();newsSyncAdapter.TableName = "documentationCategory";this.SyncAdapters.Add(newsSyncAdapter);}}on client:public class PhotoSyncAgent : SyncAgent{public PhotoSyncAgent(TableCreationOption creationOptions){this.LocalProvider = new PhotoClientSyncProvider();ServiceReference.PhotoServiceClient serviceProxy = new ServiceReference.PhotoServiceClient();this.RemoteProvider = new ServerSyncProviderProxy(serviceProxy);SyncTable documentationCategory = new SyncTable("documentationCategory");documentationCategory.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;documentationCategory.SyncDirection = SyncDirection.Bidirectional;documentationCategory.SyncGroup = new SyncGroup("documentationCategory");this.Configuration.SyncTables.Add(documentationCategory);this.Configuration.SyncParameters.Add( new SyncParameter("@Institution_ID", Utility.InstitutionID));}}so Server in my case is located on WCF side and I have a proxy generated for that, it works great!
C# developer- Marked As Answer by Sid Singh [MSFT]Microsoft Employee, Moderator Friday, October 02, 2009 7:05 PM
-
Friday, October 09, 2009 10:34 AMThanks a Lot...
Archan