Browse Source

Merge pull request #16951 from abpframework/issue-16949

Standalone servers do not support transactions for mongodb
pull/16957/head
maliming 3 years ago
committed by GitHub
parent
commit
e4ffc2ab31
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs
  2. 8
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs

20
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs

@ -18,7 +18,7 @@ namespace Volo.Abp.Uow.EntityFrameworkCore;
public class UnitOfWorkDbContextProvider<TDbContext> : IDbContextProvider<TDbContext>
where TDbContext : IEfCoreDbContext
{
private const string TransactionsNotSupportedErrorMessage = "Current database does not support transactions. Your database may remain in an inconsistent state in an error case.";
private const string TransactionsNotSupportedWarningMessage = "Current database does not support transactions. Your database may remain in an inconsistent state in an error case.";
public ILogger<UnitOfWorkDbContextProvider<TDbContext>> Logger { get; set; }
@ -189,8 +189,7 @@ public class UnitOfWorkDbContextProvider<TDbContext> : IDbContextProvider<TDbCon
}
catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e);
Logger.LogWarning(TransactionsNotSupportedWarningMessage);
return dbContext;
}
@ -227,8 +226,7 @@ public class UnitOfWorkDbContextProvider<TDbContext> : IDbContextProvider<TDbCon
}
catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e);
Logger.LogWarning(TransactionsNotSupportedWarningMessage);
return dbContext;
}
@ -245,8 +243,7 @@ public class UnitOfWorkDbContextProvider<TDbContext> : IDbContextProvider<TDbCon
}
catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e);
Logger.LogWarning(TransactionsNotSupportedWarningMessage);
return dbContext;
}
@ -284,8 +281,7 @@ public class UnitOfWorkDbContextProvider<TDbContext> : IDbContextProvider<TDbCon
}
catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e);
Logger.LogWarning(TransactionsNotSupportedWarningMessage);
return dbContext;
}
@ -327,8 +323,7 @@ public class UnitOfWorkDbContextProvider<TDbContext> : IDbContextProvider<TDbCon
}
catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e);
Logger.LogWarning(TransactionsNotSupportedWarningMessage);
return dbContext;
}
@ -345,8 +340,7 @@ public class UnitOfWorkDbContextProvider<TDbContext> : IDbContextProvider<TDbCon
}
catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e);
Logger.LogWarning(TransactionsNotSupportedWarningMessage);
return dbContext;
}

8
framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs

@ -17,7 +17,7 @@ namespace Volo.Abp.Uow.MongoDB;
public class UnitOfWorkMongoDbContextProvider<TMongoDbContext> : IMongoDbContextProvider<TMongoDbContext>
where TMongoDbContext : IAbpMongoDbContext
{
private const string TransactionsNotSupportedErrorMessage = "Current database does not support transactions. Your database may remain in an inconsistent state in an error case.";
private const string TransactionsNotSupportedWarningMessage = "Current database does not support transactions. Your database may remain in an inconsistent state in an error case.";
public ILogger<UnitOfWorkMongoDbContextProvider<TMongoDbContext>> Logger { get; set; }
protected readonly IUnitOfWorkManager UnitOfWorkManager;
@ -194,8 +194,7 @@ public class UnitOfWorkMongoDbContextProvider<TMongoDbContext> : IMongoDbContext
}
catch (NotSupportedException e)
{
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e);
Logger.LogWarning(TransactionsNotSupportedWarningMessage);
dbContext.ToAbpMongoDbContext().InitializeDatabase(database, client, null);
return dbContext;
@ -245,8 +244,7 @@ public class UnitOfWorkMongoDbContextProvider<TMongoDbContext> : IMongoDbContext
}
catch (NotSupportedException e)
{
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e);
Logger.LogWarning(TransactionsNotSupportedWarningMessage);
dbContext.ToAbpMongoDbContext().InitializeDatabase(database, client, null);
return dbContext;

Loading…
Cancel
Save