Upload filter RRS feed

  • Question

  • We are using the SQLSyncAdapterBuilder since we have a 100 tables or so and want to avoid a lot of code being generated in the manual option. However, I noticed that when I specify the FilterClause for UploadOnly using the SqlSyncAdapterBuilder, it seems to ignore this and updates everything. Is there a workaround for this??





    • Moved by Max Wang_1983 Friday, April 22, 2011 6:11 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, August 19, 2008 4:08 PM

All replies

  • I got it working. My code now looks like:


    XmlDocument xmlDocument = new XmlDocument();


    XmlElement rootElement = xmlDocument.DocumentElement;

    XmlNodeList xmlNodes = rootElement.SelectNodes("//applicationDataSection/applicationTable");

    foreach (XmlNode xmlNode in xmlNodes)


    SqlSyncAdapterBuilder syncAdapterBuilder = new SqlSyncAdapterBuilder(_serverConnection);

    syncAdapterBuilder.TableName = xmlNode.SelectSingleNode("name").InnerText;

    syncAdapterBuilder.ChangeTrackingType = ChangeTrackingType.SqlServerChangeTracking;

    syncAdapterBuilder.SyncDirection = SyncDirection.UploadOnly;

    syncAdapterBuilder.FilterClause = xmlNode.SelectSingleNode("filter").InnerText;

    SyncAdapter syncAdapter = syncAdapterBuilder.ToSyncAdapter();

    if (syncAdapterBuilder.FilterClause.Trim().Length > 0)


    syncAdapter.DeleteCommand.CommandText =


    "WHERE " + syncAdapterBuilder.FilterClause +

    " AND ");

    syncAdapter.UpdateCommand.CommandText =


    "WHERE " + syncAdapterBuilder.FilterClause +

    " AND ");


    syncAdapter.TableName = xmlNode.SelectSingleNode("name").InnerText;




    Tuesday, August 19, 2008 7:09 PM
  • I still have the issue for inserts. The SQL generated for the Insert command is:


    INSERT INTO [KnownResolution] ([knownResolutionId], [householdId]) VALUES (@knownResolutionId, @householdId) SET @sync_row_count = @@rowcount;
    How do I insert a WHERE clause into this?


    Thursday, August 21, 2008 1:09 AM
  • Hi Arshad,


    Typically you don't need hwere clause for Insert statement ( at least TSQL grammar for sqlserver wont support it ) unless you are using "insert into ... select" statement.


    So for sync service, since the insert command will use values from the dataset directly, you won't need a where clause for inserts.




    Friday, August 22, 2008 8:17 AM