添加FilterClause后,删除功能不再有效。
JuneT说filter on tracking table which is Users_tracking
但是,我没有在Users_tracking中看到IsPublished列;我只看到UserId。
感谢您的帮助!
private static void ProvisionLocal(
SqlConnection sqlLocalConn, DbSyncScopeDescription scopeDesc)
{
var Users = SqlSyncDescriptionBuilder
.GetDescriptionForTable("Users", sqlLocalConn);
scopeDesc.Tables.Add(Users);
var sqlLocalProv = new SqlSyncScopeProvisioning(sqlLocalConn, scopeDesc);
sqlLocalProv.CommandTimeout = 3600;
sqlLocalProv.Tables["Users"].AddFilterColumn("IsPublished");
sqlLocalProv.Tables["Users"].FilterClause =
string.Format("[side].[IsPublished] = {0}", 1);
if (!sqlLocalProv.ScopeExists("TestScope"))
{
sqlLocalProv.Apply();
}
}
private static void ProvisionRemote(
SqlConnection sqlRemoteConn, DbSyncScopeDescription scopeDesc)
{
var sqlRemoteProv = new SqlSyncScopeProvisioning(sqlRemoteConn, scopeDesc);
sqlRemoteProv.CommandTimeout = 3600;
if (!sqlRemoteProv.ScopeExists("TestScope"))
{
// Apply the scope provisioning.
sqlRemoteProv.Apply();
}
}
public void Synchronize()
{
var sqlSourceConn = new SqlConnection("...");
var sqlDestinationConn = new SqlConnection("...");
var scopeDesc = new DbSyncScopeDescription("TestScope");
ProvisionLocal(type, sqlSourceConn, scopeDesc);
ProvisionRemote(type, sqlDestinationConn, scopeDesc);
// Prepare for synchronization
var localProvider = new SqlSyncProvider("TestScope", sqlSourceConn);
var remoteProvider = new SqlSyncProvider("TestScope", sqlDestinationConn);
remoteProvider.ApplyChangeFailed += RemoteProvider_ApplyChangeFailed;
var orch = new SyncOrchestrator();
orch.RemoteProvider = remoteProvider;
orch.LocalProvider = localProvider;
orch.Direction = SyncDirectionOrder.Upload;
SyncOperationStatistics stats = orch.Synchronize();
sqlDestinationConn.Close();
sqlSourceConn.Close();
}
答案 0 :(得分:1)
IsPublished列位于跟踪表的底部...
是你另一个范围的表格部分吗?你在增加另一个范围吗?