Created
July 17, 2014 15:05
-
-
Save mgroves/790c057fccf64aa92c5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Data; | |
namespace Ledger.Models | |
{ | |
public interface ICommand | |
{ | |
void Execute(IDbConnection db); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Ledger.Models.CommandQuery; | |
namespace Ledger.Models | |
{ | |
public interface IDatabase | |
{ | |
T Query<T>(IQuery<T> query); | |
void Execute(ICommand command); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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