Browse Source

Added EnableObsoleteDbContextCreationWarning to disable logs.

pull/7210/head
Halil İbrahim Kalkan 5 years ago
parent
commit
9eb6a63f31
  1. 3
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs
  2. 3
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs
  3. 6
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs
  4. 7
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManager.cs

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

@ -39,7 +39,8 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
[Obsolete("Use GetDbContextAsync method.")]
public TDbContext GetDbContext()
{
if (!UnitOfWork.DisableObsoleteDbContextCreationWarning.Value)
if (UnitOfWork.EnableObsoleteDbContextCreationWarning &&
!UnitOfWorkManager.DisableObsoleteDbContextCreationWarning.Value)
{
Logger.LogWarning(
"UnitOfWorkDbContextProvider.GetDbContext is deprecated. Use GetDbContextAsync instead! " +

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

@ -36,7 +36,8 @@ namespace Volo.Abp.Uow.MongoDB
[Obsolete("Use CreateDbContextAsync")]
public TMongoDbContext GetDbContext()
{
if (!UnitOfWork.DisableObsoleteDbContextCreationWarning.Value)
if (UnitOfWork.EnableObsoleteDbContextCreationWarning &&
!UnitOfWorkManager.DisableObsoleteDbContextCreationWarning.Value)
{
Logger.LogWarning(
"UnitOfWorkDbContextProvider.GetDbContext is deprecated. Use GetDbContextAsync instead! " +

6
framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs

@ -11,8 +11,10 @@ namespace Volo.Abp.Uow
{
public class UnitOfWork : IUnitOfWork, ITransientDependency
{
[Obsolete("This will be removed in next versions.")]
public static AsyncLocal<bool> DisableObsoleteDbContextCreationWarning { get; } = new AsyncLocal<bool>();
/// <summary>
/// Default: false.
/// </summary>
public static bool EnableObsoleteDbContextCreationWarning { get; } = false;
public const string UnitOfWorkReservationName = "_AbpActionUnitOfWork";

7
framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManager.cs

@ -1,10 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Uow
{
public class UnitOfWorkManager : IUnitOfWorkManager, ISingletonDependency
{
[Obsolete("This will be removed in next versions.")]
public static AsyncLocal<bool> DisableObsoleteDbContextCreationWarning { get; } = new AsyncLocal<bool>();
public IUnitOfWork Current => GetCurrentUnitOfWork();
private readonly IServiceScopeFactory _serviceScopeFactory;

Loading…
Cancel
Save