locked
How to apply filter in syncservice. RRS feed

  • Question

  • I'm just getting started with sync services and have a question about applying filters that I haven't been able to find an answer to.  In VS 2008, I create a local db cache (via Add New Item).  I would like to apply a filter before the cache is filled with data.  However, with these options the wizard downloads all the data. 

    I just follow this URL : http://msdn.microsoft.com/en-us/library/bb726003.aspx

    here i'm getting targetinvocation exception. actually the code is :

    using

     

    Microsoft.Synchronization.Data.Server;

    using

     

    System.Data.SqlClient;

    namespace

     

    LibraryService {

     

     

     

    public partial class LibraryCacheServerSyncProvider: DbServerSyncProvider {

     

     

    partial void OnInitialized(){

     

    string connStr = System.Configuration.ConfigurationSettings.AppSettings["ServerLibraryConnectionString"];

     

    SqlConnection serverConn = new SqlConnection(connStr);

     

    this.Connection = serverConn;

     

    SqlSyncAdapterBuilder bookBuilder = new SqlSyncAdapterBuilder(serverConn);

    bookBuilder.TableName =

    "Book";

    bookBuilder.FilterClause =

    "Publication='BPB'";

     

    SyncAdapter bookSyncAdapter = bookBuilder.ToSyncAdapter();

    bookSyncAdapter.TableName =

    "Book";

     

    this.SyncAdapters.Add(bookSyncAdapter);

    }

    }

    }

     

    Monday, September 27, 2010 11:54 AM

Answers

  • the Local Database Cache designer doesnt support providing a filter in the design wizard, so you will always end up with an unfiltered data when using the wizard.

    would you mind posting the stack trace to the error your're getting when adding the filter?

    Monday, September 27, 2010 3:11 PM