Last active
September 26, 2015 22:08
-
-
Save WilliamBerryiii/a01da8b9f53732bad4b4 to your computer and use it in GitHub Desktop.
Example Basic C# Data Accessor/Repository
This file contains 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
public class Repository | |
{ | |
private ISqlExecutioner _sqlExecutioner; | |
private string _connectionString; | |
public Repository (ISqlExecutioner sqlExecutioner, string connectionString) | |
{ | |
_sqlExecutioner = sqlExecutioner; | |
_connectionString = connectionString; | |
} | |
public static DataSet GetSomeStuffFromTheDatabase(int thingId) | |
{ | |
const string PROCEDURE_NAME = "GetMeSomeData"; | |
var parameterLisst = new SqlParameterList(); | |
parameterList.Add("@thing_id", SqlDbType.Int, thingId); | |
return _sqlExecutioner.ExecuteQuery(_connectionString, PROCEDURE_NAME, parameterList); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment