2009-07-16 2 views
3

그래서 지금까지 내가 가지고있는 것입니다. 내가 잘못했거나 3.0.0.3에 버그가 있습니까?아음속 3 간단한 저장소 및 트랜잭션

var Repository = new SimpleRepository("DBConnectionName"); 

    using (TransactionScope ts = new TransactionScope()) 
    { 
     using (SharedDbConnectionScope scs = new SharedDbConnectionScope("connstring", "providerName")) 
     { 
      try 
      { 
       for (int i = 0; i < 5; i++) 
       { 
        Supplier s = new Supplier(); 
        s.SupplierCode = i.ToString(); 
        s.SupplierName = i.ToString(); 

        Repository.Add<Supplier>(s); 
       } 

       ts.Complete(); 
      } 
      catch 
      { 
      } 
     } 
    } 

나는 음속 DbDataProvider 공공 DbConnection CurrentSharedConnection { GET {반환 __sharedConnection에 오류를 받고 있어요; }

 protected set 
     { 
      if(value == null) 
      { 
       __sharedConnection.Dispose(); 

등 __sharedConnection는 == 널 (null) :(객체 null 참조 예외 :(

답변

0

마지막으로 이것을 해결했습니다. 위의 코드는 모두 (SubSonic 3.0.0.3, SQLite 사용) 작동하지 않지만 BeginTransaction()을 추가하면 예외가 발생할 경우 트랜잭션 속도가 크게 빨라지고 업데이트가 롤백됩니다.

완성도를 들어
using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope(Access.Provider)) 
{ 
    using (IDbTransaction ts = sharedConnectionScope.CurrentConnection.BeginTransaction()) 
    { 
     IRepository repo = new SimpleRepository(Access.Provider); 
     //Do your database updates 

     //throw new ApplicationException("Uncomment this and see if the updates get rolled back"); 
     ts.Commit(); 
    } 
} 

: Access.Providerreturn SubSonic.DataProviders.ProviderFactory.GetProvider(ConnectionString, "System.Data.SQLite");

를 돌려 나를 위해 헬퍼 클래스의 정적 속성입니다
0

는 아마도 SharedDbConnectionScope 및 TransactionScope의 전환은 주변에 도움이 될 수 있습니다.이 때 마이그레이션이 일어날

using (SharedDbConnectionScope scs = new SharedDbConnectionScope("connstring", "providerName")) 
{ 
    using (TransactionScope ts = new TransactionScope()) 
    { 
    } 
} 
0

설정 됨 - 테이블 이동시 데이터베이스 연결이 닫힙니다.

SimpleRepositoryOption을 사용하여 SimpleRepository를 시도하십시오. 안돼.

이것이 버그인지 잘 모름 트랜잭션이 SimpleRepository와 작동하지 않는다고 생각합니다. 트랜잭션의 예외를 throw 할 때 저장되는 데이터의 절반이 항상 있습니다. 아마도 ActiveRecord에만 해당할까요? 아무도 몰라?