Ignore TransactionScope for specific query

后端 未结 3 1648
星月不相逢
星月不相逢 2020-12-13 19:12

I\'m looking for a way to execute a query while a TransactionScope is alive, and ignore the TransactionScope - basically, I want to execute this particular query no matter w

3条回答
  •  爱一瞬间的悲伤
    2020-12-13 19:18

    Just my initial thought, but you need to put your LogRepo on it's own DataContext (DC2) so that the surrounding TransactionScope (with DC1) won't roll it back when it's not committed.

    Basically, you need to make your logging self-contained and atomic.

    EDIT In looking at it some more, it seems to me that if you moved your Logging out from the SaveChanges into the catch() on DoSomething(), your logging would work. But, your logging still needs to be self-contained and atomic.

提交回复
热议问题