EF 코드 첫 번째 DBContext 및 거래
-
14-11-2019 - |
문제
나는 무엇이 최선의 방법으로 구현하는 트랜잭션 DBContext
.특히,
- 가
DbContext.SaveChanges
를 구현하는 트랜잭션 internall 변경하는 경우 여러 요소? - 고 싶으면 전화
DbContext.SaveChanges
여러 배(동 contxet/다 contxets)는 방법,트랜잭션 달성될 수 있다고 보십니까?
해결책
- 그렇습니다.
SaveChanges
용 트랜잭션 내부적으로 합니다. - 사
TransactionScope
을 감싸는 여러 통화SaveChanges
예제:
using(var scope = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
{
// Do something
context.SaveChanges();
// Do something else
context.SaveChanges();
scope.Complete();
}
제휴하지 않습니다 StackOverflow