Skip to content

Commit

Permalink
Use IDbConnection instead of SqlConnection (fixes half-ogre#1)
Browse files Browse the repository at this point in the history
Allows usage of classes that don't derive from SqlConnection, such as
ProfiledDbConnection
  • Loading branch information
davidduffett committed Oct 3, 2012
1 parent d4a43c9 commit 6069978
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions DapperWrapper/SqlExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Dapper;

namespace DapperWrapper
{
public class SqlExecutor : IDbExecutor
{
readonly SqlConnection _sqlConnection;
readonly IDbConnection _dbConnection;

public SqlExecutor(SqlConnection sqlConnection)
public SqlExecutor(IDbConnection dbConnection)
{
_sqlConnection = sqlConnection;
_dbConnection = dbConnection;
}

public int Execute(
Expand All @@ -21,7 +20,7 @@ public int Execute(
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?))
{
return _sqlConnection.Execute(
return _dbConnection.Execute(
sql,
param,
transaction,
Expand All @@ -37,7 +36,7 @@ public IEnumerable<dynamic> Query(
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?))
{
return _sqlConnection.Query(
return _dbConnection.Query(
sql,
param,
transaction,
Expand All @@ -54,7 +53,7 @@ public IEnumerable<T> Query<T>(
int? commandTimeout = default(int?),
CommandType? commandType = default(CommandType?))
{
return _sqlConnection.Query<T>(
return _dbConnection.Query<T>(
sql,
param,
transaction,
Expand All @@ -65,7 +64,7 @@ public IEnumerable<T> Query<T>(

public void Dispose()
{
_sqlConnection.Dispose();
_dbConnection.Dispose();
}
}
}

0 comments on commit 6069978

Please sign in to comment.