Skip to content

Commit

Permalink
Quirk for #23350
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Nov 17, 2020
1 parent 2d0a835 commit 361ae11
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal
/// </summary>
public class SqlServerTransaction : RelationalTransaction
{
private static readonly bool _useOldBehavior
= AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23350", out var enabled) && enabled;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -49,6 +52,11 @@ public override bool SupportsSavepoints
{
get
{
if (_useOldBehavior)
{
return base.SupportsSavepoints;
}

if (Connection is ISqlServerConnection sqlServerConnection && sqlServerConnection.IsMultipleActiveResultSetsEnabled)
{
Logger.SavepointsDisabledBecauseOfMARS();
Expand Down
13 changes: 12 additions & 1 deletion src/EFCore/Diagnostics/WarningsConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
Expand All @@ -21,6 +22,9 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics
/// </summary>
public class WarningsConfiguration
{
private static readonly bool _useOldBehavior
= AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23350", out var enabled) && enabled;

private Dictionary<int, (WarningBehavior? Behavior, LogLevel? Level)> _explicitBehaviors
= new Dictionary<int, (WarningBehavior? Behavior, LogLevel? Level)>();

Expand Down Expand Up @@ -172,7 +176,14 @@ public virtual long GetServiceProviderHashCode()

if (_explicitBehaviors != null)
{
hashCode = _explicitBehaviors.OrderBy(b => b.Key).Aggregate(
IEnumerable<KeyValuePair<int, (WarningBehavior? Behavior, LogLevel? Level)>> explicitBehaviors = _explicitBehaviors;

if (!_useOldBehavior)
{
explicitBehaviors = _explicitBehaviors.OrderBy(b => b.Key);
}

hashCode = explicitBehaviors.Aggregate(
hashCode,
(t, e) => (t * 397) ^ (((long)e.Value.GetHashCode() * 3163) ^ (long)e.Key.GetHashCode()));
}
Expand Down

0 comments on commit 361ae11

Please sign in to comment.