@ -70,7 +70,7 @@ namespace Volo.Abp.Uow.MongoDB
var databaseName = mongoUrl . DatabaseName ;
if ( databaseName . IsNullOrWhiteSpace ( ) )
{
databaseName = ConnectionStringNameAttribute . GetConnStringName < TMongoDbContext > ( ) ;
databaseName = ConnectionStringNameAttribute . GetConnStringName ( targetDbContextType ) ;
}
//TODO: Create only single MongoDbClient per connection string in an application (extract MongoClientCache for example).
@ -98,7 +98,7 @@ namespace Volo.Abp.Uow.MongoDB
var databaseName = mongoUrl . DatabaseName ;
if ( databaseName . IsNullOrWhiteSpace ( ) )
{
databaseName = ConnectionStringNameAttribute . GetConnStringName < TMongoDbContext > ( ) ;
databaseName = ConnectionStringNameAttribute . GetConnStringName ( targetDbContextType ) ;
}
//TODO: Create only single MongoDbClient per connection string in an application (extract MongoClientCache for example).
@ -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 (