DBContext的事务性封装

It is not necessary to wrap your SaveChanges call in another TransactionScope if; If you are not trying to use multiple context in the same transaction. If you are not making multiple SaveChanges calls even with the same context. For instance, one SaveChanges after Delete, another SaveChanges after add... In summary, you can do multiple delete/add operations with the same context, and call the SaveChanges method once in the end - they will all be applied in one transaction. TransactionScope is only necessary if you have nested transaction scenarios.

posted @ 2014-02-27 16:01  本杰明·喝茶  阅读(372)  评论(0)    收藏  举报