@@ -41,7 +41,7 @@ protected virtual async ValueTask<TDbContext> GetDbContextAsync(CancellationToke
4141
4242 protected virtual TDbContext GetDbContext ( ) => _lazyDb . Value ;
4343
44- public bool TryCreateTransaction ( ) {
44+ public virtual bool TryCreateTransaction ( ) {
4545 if ( _transaction != null ) return false ;
4646
4747 var dbContext = GetDbContext < TDbContext > ( ) ;
@@ -75,7 +75,7 @@ public virtual async ValueTask<bool> TryCreateTransactionAsync(CancellationToken
7575 }
7676 }
7777
78- public void SaveChanges ( ) {
78+ public virtual void SaveChanges ( ) {
7979 DbContext dbContext = GetDbContext < TDbContext > ( ) ;
8080 dbContext . SaveChanges ( ) ;
8181 }
@@ -85,7 +85,7 @@ public virtual async ValueTask SaveChangesAsync(CancellationToken ct = default)
8585 await dbContext . SaveChangesAsync ( ct ) ;
8686 }
8787
88- public bool TryCommitTransaction ( ) {
88+ public virtual bool TryCommitTransaction ( ) {
8989 if ( _transaction == null ) return false ;
9090
9191 lock ( _transactionLock ) {
@@ -111,7 +111,7 @@ public virtual async ValueTask<bool> TryCommitTransactionAsync(CancellationToken
111111 }
112112 }
113113
114- public bool TryRollbackTransaction ( ) {
114+ public virtual bool TryRollbackTransaction ( ) {
115115 if ( _transaction == null ) return false ;
116116
117117 _transaction . Rollback ( ) ;
@@ -131,7 +131,7 @@ public virtual async ValueTask<bool> TryRollbackTransactionAsync(CancellationTok
131131 return true ;
132132 }
133133
134- public bool TryRollbackToSavepoint ( Guid id ) {
134+ public virtual bool TryRollbackToSavepoint ( Guid id ) {
135135 if ( _transaction == null ) return false ;
136136 if ( ! _transaction . SupportsSavepoints ) return false ;
137137
@@ -148,7 +148,7 @@ public virtual async ValueTask<bool> TryRollbackToSavepointAsync(Guid id, Cancel
148148 return true ;
149149 }
150150
151- public bool TryCreateSavepoint ( Guid id ) {
151+ public virtual bool TryCreateSavepoint ( Guid id ) {
152152 if ( _transaction == null ) return false ;
153153 if ( ! _transaction . SupportsSavepoints ) return false ;
154154
@@ -165,7 +165,7 @@ public virtual async ValueTask<bool> TryCreateSavepointAsync(Guid id, Cancellati
165165 return true ;
166166 }
167167
168- public T GetDbContext < T > ( ) where T : DbContext {
168+ public virtual T GetDbContext < T > ( ) where T : DbContext {
169169 if ( typeof ( T ) != typeof ( TDbContext ) ) throw new NotSupportedException ( $ "DbContext type '{ typeof ( T ) } ' is not supported by this UnitOfWork.") ;
170170
171171 TDbContext dbContext = GetDbContext ( ) ;
@@ -181,7 +181,7 @@ public virtual async ValueTask<T> GetDbContextAsync<T>(CancellationToken ct = de
181181 return Unsafe . As < TDbContext , T > ( ref dbContext ) ;
182182 }
183183
184- public TRepo GetRepository < TRepo > ( ) where TRepo : class , IUnitOfWorkRepository {
184+ public virtual TRepo GetRepository < TRepo > ( ) where TRepo : class , IUnitOfWorkRepository {
185185 if ( AttachedRepositories . TryGetValue ( typeof ( TRepo ) , out IUnitOfWorkRepository ? cachedRepo ) && cachedRepo is TRepo castedCachedRepo ) return castedCachedRepo ;
186186
187187 var repo = CreateAndAttachRepository < TRepo > ( ) ;
0 commit comments