开发者

Transactionscope and deadlocks when using enterprise library

We are using Enterprise Library for data access.

One of our methods has a de开发者_StackOverflow社区lete and then an insert, against the same table. This gives a deadlock.

If we put these inside a transaction scope the deadlock no longer occurs.

Intuitively, it feels like it should be the opposite way around. Can anyone explain why it works like this?


Transaction scope combined with TransactionOptions IsolationLevel = IsolationLevel.ReadUncommitted is equivalent to WITH(NOLOCK) in T-SQL so if the table is not locked the deadlocks don't occur...

using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions(){ IsolationLevel = IsolationLevel.ReadUncommitted }))
{
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜