我们的中央数据库将以中心辐射方式同步。
我们需要能够以客户端数据仅在本地复制到该客户端的方式对数据进行分区。
有没有人遇到过这个问题?
MSF 提供同步范围 - 表的声明是同步的,可以选择指定 filtercolumn 和 filter 子句,但是似乎没有办法将参数(比如 clientID)传递给过滤器。
下面是 msdn 文档中的示例:
' Create a scope named "filtered_customer", and add two tables to the scope.
' GetDescriptionForTable gets the schema of each table, so that tracking
' tables and triggers can be created for that table.
Dim scopeDesc As New DbSyncScopeDescription("filtered_customer")
scopeDesc.Tables.Add(SqlSyncDescriptionBuilder.GetDescriptionForTable("Customer", serverConn))
scopeDesc.Tables.Add(SqlSyncDescriptionBuilder.GetDescriptionForTable("CustomerContact", serverConn))
' Create a provisioning object for "filtered_customer" and specify that
' base tables should not be created (They already exist in SyncSamplesDb_SqlPeer1).
Dim serverConfig As New SqlSyncScopeProvisioning(scopeDesc)
serverConfig.CreateTableDefault = DbSyncCreationOption.Skip
' Specify which column(s) in the Customer table to use for filtering data,
' and the filtering clause to use against the tracking table.
' "[side]" is an alias for the tracking table.
serverConfig("Customer").AddFilterColumn("CustomerType")
serverConfig("Customer").FilterClause = "[side].[CustomerType] = 'Retail'"
' Configure the scope and change tracking infrastructure.
serverConfig.Apply(serverConn)
我们的问题是,我们需要将过滤器排除在客户端ID 之外作为运行时参数。
MSF 支持吗?
如果不是,也许这可以通过声明多个范围来实现 - 为每个客户端声明一个范围,过滤子句指定客户端 ID。这将要求每次我们创建新客户端时重新配置服务器......对吗?
有谁知道是否可以使用 SqlSyncScopeProvisioning 类将新范围添加到已经配置了现有范围的数据库?
似乎 MSF 已被设计为支持多个范围,我不清楚 SqlSyncScopeProvisioning 类是如何用于添加其他范围的。