Skip to content

Instantly share code, notes, and snippets.

@mgroves
Created July 17, 2014 15:05
Show Gist options
  • Save mgroves/790c057fccf64aa92c5d to your computer and use it in GitHub Desktop.
Save mgroves/790c057fccf64aa92c5d to your computer and use it in GitHub Desktop.
using System.Data;
namespace Ledger.Models
{
public class Database : IDatabase
{
readonly IDbConnection _db;
public Database(IDbConnection db)
{
this._db = db;
}
public T Query<T>(IQuery<T> query)
{
return query.Execute(_db);
}
public void Execute(ICommand command)
{
command.Execute(_db);
}
}
}
using System.Data;
namespace Ledger.Models
{
public interface ICommand
{
void Execute(IDbConnection db);
}
}
using Ledger.Models.CommandQuery;
namespace Ledger.Models
{
public interface IDatabase
{
T Query<T>(IQuery<T> query);
void Execute(ICommand command);
}
}
using System.Data;
namespace Ledger.Models
{
public interface IQuery<T>
{
T Execute(IDbConnection db);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment