locked
Filters not applying RRS feed

  • Question

  • Hi everyone any help with this problem would be greatly appreciated. I'm trying to provision a server for syncing base on a filtered value.The idea here is that each table on the server will have a scope defining a filter for each country. So each table will end up with(in the example below) 3 scope one with a filter for country1 and two more for country 2+3.
    The code I am using is below and it does run and creates the multiple scopes for each table the only problem for some reason it only applies a filter for the first country in the array. In this example country1 but if country1 and 2 were swapped it would be country2.
    Every table is getting a scope with a filter for country1 and scopes without the filter clause for country2 and 3. I really have no idea why this is happening.
    Again any help is welcome and thank you in advance.
     string[] countriesArray = new string[3] { "Country1", "Country2", "Country3" };
     string[] tablesArray = new string[3] { "table1","table2","table3"};
       
    for (int i = 0; i < countriesArray.Length; i++)
       {
        for (int j = 0; j < tablesArray.Length; j++)
        {
         
         DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("" + tablesArray[j] + "-" + countriesArray[i] + "");
         
         DbSyncTableDescription tableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable(tablesArray[j], serverConn);
         scopeDesc.Tables.Add(tableDesc);
         
         SqlSyncScopeProvisioning serverProvision = new SqlSyncScopeProvisioning(serverConn, scopeDesc);
         serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip);
         
         serverProvision.Tables[tablesArray[j]].AddFilterColumn("CountryName");
         
         serverProvision.Tables[tablesArray[j]].FilterClause = "[side].[CountryName] = '" + countriesArray[i] + "'";
         Console.WriteLine("set filter value");
         serverProvision.CommandTimeout = 60;
         
         serverProvision.Apply();
    
    
        }
       }
       
    
    Regards,
    David
    Saturday, July 16, 2011 12:17 PM

Answers

  • im assuming youre only seeing one selectchanges sp.

    use SetCreateProceduresForAdditionalScopeDefault for the 2nd and subsequent scope in the same table so that Sync Fx creates one selectchanges sp for each scope.

    I would also advice you explore using filtered scope templates.

     

    Saturday, July 16, 2011 5:47 PM

All replies

  • im assuming youre only seeing one selectchanges sp.

    use SetCreateProceduresForAdditionalScopeDefault for the 2nd and subsequent scope in the same table so that Sync Fx creates one selectchanges sp for each scope.

    I would also advice you explore using filtered scope templates.

     

    Saturday, July 16, 2011 5:47 PM
  • Thanks JuneT worked like a charm. Filtered Scope Templates are probably the right way to go but i'm on a bit of a tight deadline and have to work with what i've got. 

    Thanks again.

    Monday, July 18, 2011 9:50 AM