1
我想禁用,然後重建同步事務內的唯一索引。可以做到嗎?同步框架 - 如何啓用和禁用同步事務內的唯一索引?
我在表中有多個行需要更改,但更新的值違反了唯一索引。但是,在所有行更改後,約束都會得到滿足,所以我希望在同步過程結束之前禁用此索引。
我想禁用,然後重建同步事務內的唯一索引。可以做到嗎?同步框架 - 如何啓用和禁用同步事務內的唯一索引?
我在表中有多個行需要更改,但更新的值違反了唯一索引。但是,在所有行更改後,約束都會得到滿足,所以我希望在同步過程結束之前禁用此索引。
如果有人有興趣在解決類似的問題 - 一個可以接管連接到同步提供的一些事件同步過程中使用的事務控制:
private void DbCacheServerSyncProvider_ApplyingChanges(object sender, ApplyingChangesEventArgs e)
{
if (e.Transaction == null)
{
e.Transaction = e.Connection.BeginTransaction(IsolationLevel.ReadCommitted);
DisableConstraints(e.Connection, e.Transaction);
}
}
private void DbCacheServerSyncProvider_ChangesApplied(object sender, ChangesAppliedEventArgs e)
{
if (e.Transaction != null)
{
EnableConstraints(e.Connection, e.Transaction);
e.Transaction.Commit();
e.Transaction.Dispose();
}
}
private void DbCacheServerSyncProvider_ApplyChangeFailed(object sender, ApplyChangeFailedEventArgs e)
{
if (e.Transaction != null)
{
e.Transaction.Rollback();
e.Transaction.Dispose();
}
throw new InternalException("Server-side conflict has occurred during synchronization. Conflict details:\r\n" + SyncUtils.CreateChangeFailedDetails(e).Trim('\r', '\n'));
}
我已經更新的問題。 – 2010-11-20 09:53:51