Files
Umbraco-CMS/src/Umbraco.Infrastructure/Persistence/DbCommandExtensions.cs

30 lines
858 B
C#
Raw Normal View History

2016-12-14 14:06:30 +01:00
using System.Data;
namespace Umbraco.Core.Persistence
{
internal static class DbCommandExtensions
{
/// <summary>
/// Unwraps a database command.
/// </summary>
/// <remarks>UmbracoDatabase wraps the original database connection in various layers (see
/// OnConnectionOpened); this unwraps and returns the original database command.</remarks>
public static IDbCommand UnwrapUmbraco(this IDbCommand command)
{
IDbCommand unwrapped;
var c = command;
do
{
unwrapped = c;
var profiled = unwrapped as StackExchange.Profiling.Data.ProfiledDbCommand;
if (profiled != null) unwrapped = profiled.InternalCommand;
} while (c != unwrapped);
return unwrapped;
}
}
}