Quick Note: How To Filter Which Tables You Sync

by Bill Forney 21. October 2010 02:37

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: ,
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags: ,

Software Development | Technology | SQL Azure | Sync Framework

Powered by BlogEngine.NET 1.6.2.17
Theme by Extensive SEO

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.