Quick Note: How To Filter Which Tables You Sync

I’m messing with sync framework and am just posting this as a quick note to self, but it might help others too. When syncing with a custom scope I’m using this code to filter on a column.

   1:  var sqlAzureProvisioning = new SqlSyncScopeProvisioning(sqlAzureConnection, scope);
   2:  if (!sqlAzureProvisioning.ScopeExists(FilteredScopeName))
   3:  {
   4:      sqlAzureProvisioning.SetCreateTableDefault(DbSyncCreationOption.CreateOrUseExisting);
   5:      sqlAzureProvisioning.SetCreateTrackingTableDefault(DbSyncCreationOption.CreateOrUseExisting);
   6:      sqlAzureProvisioning.SetCreateTriggersDefault(DbSyncCreationOption.CreateOrUseExisting);
   7:      sqlAzureProvisioning.SetCreateProceduresDefault(DbSyncCreationOption.CreateOrUseExisting);
   8:      sqlAzureProvisioning.SetCreateProceduresForAdditionalScopeDefault(DbSyncCreationOption.CreateOrUseExisting);
   9:      sqlAzureProvisioning.ObjectSchema = "Sync";
  10:   
  11:      sqlAzureProvisioning.Tables["Contacts"].AddFilterColumn("OwnerContactId");
  12:      sqlAzureProvisioning.Tables["Contacts"].FilterClause =
  13:          string.Format("[side].[OwnerContactId] = '{0}'", Properties.Settings.Default.UserContactId);
  14:   
  15:      sqlAzureProvisioning.Apply();
  16:  }

Technorati Tags: ,

    Month List

    Recent Tweets

    Twitter May 3, 14:32
    New blog post: http://t.co/4oTIhV1rML - To observe or not to observe? That is the question…

    Twitter April 8, 23:17
    #SignalR is fun

    Twitter December 20, 04:04
    Updated blog post: http://t.co/ETo7eiH5 - A Quick Comparison Between jsViews and Knockout

    Twitter December 10, 16:44
    Haha

    @wforney

    Widget Twitter not found.

    Root element is missing.X

    VSAchievements

    Visual Studio Achievements
    Bill Forney (157 Points)
     
    Bill's bookshelf: read

    How to Win Friends & Influence People Getting Things Done: The Art of Stress-Free Productivity The Fellowship of the Ring The Dragon Reborn A Game of Thrones Towers of Midnight

    More of Bill's books »
    Book recommendations, book reviews, quotes, book clubs, book trivia, book lists

    Recent Comments

    Comment RSS

    About the author

    William L. Forney was born in Pennsylvania and relocated to Washington State in early 1999. His hobbies include all the usual things: movies, books, music, video games, etc. He writes short sci-fi/fantasy stories which will someday be published in the form of small novels.

    Bill's Photograph

    He loves computers and has worked in several different areas from web, multimedia, video and 3D animation to database and windows development.

    Currently he works at Visible Reality, LLC as the lead developer and improvGroup, LLC as a networking consultant.

    He also works with Padgett & Padgett, PLLC, the accounting firm where he setup shop after moving.

    His other blog can be found here.