문제

나는 무엇이 최선의 방법으로 구현하는 트랜잭션 DBContext.특히,

  1. DbContext.SaveChanges 를 구현하는 트랜잭션 internall 변경하는 경우 여러 요소?
  2. 고 싶으면 전화 DbContext.SaveChanges 여러 배(동 contxet/다 contxets)는 방법,트랜잭션 달성될 수 있다고 보십니까?
도움이 되었습니까?

해결책

  1. 그렇습니다. SaveChanges 용 트랜잭션 내부적으로 합니다.
  2. 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();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top