Search code examples
c#sql-serverwindows-mobilemicrosoft-sync-framework

Limiting records synchronized to mobile device


Similar questions have been asked before but after a day of going through the answers I'm still very confused.

I'm using Microsoft's Sync Framework with SQL2008 on the server and SQL CE on Windows Mobile devices. I would have thought this was a VERY common requirement. I don't want to replicate large tables onto the mobile device. I only want the records that are needed. For example, each user will need their "jobs" out of the jobs table. They don't need any other user's jobs. So I need something like "where jobId = 3" for one device and "where jobId=4" for another etc.

This looked promising: http://jtabadero.spaces.live.com/blog/cns!BF49A449953D0591!1203.entry

but unfortunately it doesn't work with my code. This code from the sample seems to be trying to get the code that contains the SQL:

var remoteProvider = (LocalDataCache1ServerSyncProvider)syncAgent.RemoteProvider; 

var selectIncrementalInsertsCommand = remoteProvider.SalesLT_CustomerSyncAdapter.SelectIncrementalInsertsCommand; 

BUT the code containing the SQL (generated by VS) is on the server-side and only a proxy is available in the client-side code. This is how the proxy is added:

// The WCF Service
var webSvcProxy = new MicronetCacheSyncService();

// The Remote Server Provider Proxy
var serverProvider = new ServerSyncProviderProxy(webSvcProxy);

// The Sync Agent
var syncAgent = new MicronetCacheSyncAgent();
syncAgent.RemoteProvider = serverProvider;

So how can I get to the server-side code that contains the sql from the client-side? Sorry I'm not explaining this very well but I guess it's unlikely anyone will have an answer. The short version is does anyone know a SIMPLE way to limit the records that are synced to a mobile device is this type of app? I think the example was meant for desktop apps.

It looks to me like this sync framework is another one of Microsoft's half-baked releases that is really just a beta. It's starting to remind me of some previous horrible experiences with Entity Framework 1.0 :(


Solution

  • The tutorial at http://msdn.microsoft.com/en-us/library/dd918848%28SQL.105%29.aspx contains everything you need to provision filtering for a scope.

    FYI, that tutorial is for Sync Framework 2.0, whereas from your code above it appears you're using Sync Framework 1.0 -- a legacy product.