Skip to content

Instantly share code, notes, and snippets.

@krk
Created June 3, 2014 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krk/e588d0c72c3386959d5e to your computer and use it in GitHub Desktop.
Save krk/e588d0c72c3386959d5e to your computer and use it in GitHub Desktop.
MiniProfiler DbDataAdapter DbCommand type mismatch exception workaround
public class ProfiledDbProviderFactoryAlwaysProfiled : ProfiledDbProviderFactory
{
private readonly DbProviderFactory _tail;
public ProfiledDbProviderFactoryAlwaysProfiled(DbProviderFactory tail)
: base(tail)
{
_tail = tail;
}
public override DbCommand CreateCommand()
{
DbCommand command = this._tail.CreateCommand();
return new ProfiledDbCommand(command, null, MiniProfiler.Current);
}
public override DbConnection CreateConnection()
{
DbConnection connection = this._tail.CreateConnection();
return new ProfiledDbConnection(connection, MiniProfiler.Current);
}
public override DbDataAdapter CreateDataAdapter()
{
DbDataAdapter dataAdapter = this._tail.CreateDataAdapter();
return new ProfiledDbDataAdapter(dataAdapter, MiniProfiler.Current);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment