2010-11-20 55 views

回答

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')); 
} 
0

如果您沒有更改唯一索引,則無需這樣做。

有了SQL Server 2008,您可以執行聯機重新組織或重建:

你到底想幹什麼?

+0

我已經更新的問題。 – 2010-11-20 09:53:51