Browse Source
Merge pull request #10658 from abpframework/MongoDb-Transactions
Log errors and not using if the current MongoDB does not support transactions.
pull/10671/head
Halil İbrahim Kalkan
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
24 additions and
2 deletions
framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs
@ -184,7 +184,18 @@ namespace Volo.Abp.Uow.MongoDB
session . AdvanceOperationTime ( new BsonTimestamp ( unitOfWork . Options . Timeout . Value ) ) ;
}
session . StartTransaction ( ) ;
try
{
session . StartTransaction ( ) ;
}
catch ( NotSupportedException e )
{
Logger . LogError ( "The current MongoDB database does not support transactions, All operations will be performed in non-transactions, This may cause errors." ) ;
Logger . LogException ( e ) ;
dbContext . ToAbpMongoDbContext ( ) . InitializeDatabase ( database , client , null ) ;
return dbContext ;
}
unitOfWork . AddTransactionApi (
transactionApiKey ,
@ -224,8 +235,19 @@ namespace Volo.Abp.Uow.MongoDB
session . AdvanceOperationTime ( new BsonTimestamp ( unitOfWork . Options . Timeout . Value ) ) ;
}
session . StartTransaction ( ) ;
try
{
session . StartTransaction ( ) ;
}
catch ( NotSupportedException e )
{
Logger . LogError ( "The current MongoDB database does not support transactions, All operations will be performed in non-transactions, This may cause errors." ) ;
Logger . LogException ( e ) ;
dbContext . ToAbpMongoDbContext ( ) . InitializeDatabase ( database , client , null ) ;
return dbContext ;
}
unitOfWork . AddTransactionApi (
transactionApiKey ,
new MongoDbTransactionApi (