Skip to content

Simple utility class to manage SQL connection and execution of SQL queries

Notifications You must be signed in to change notification settings

tzelewski/DataAccessRepo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DataAccessRepo

Simple utility class to manage SQL connection and execution of SQL queries

It provides an easy way to abstract out the creation, usage and maintenance of IDbConnection, DbCommand and DbDataReader. Easy to use, inject and unit test.

Example usage:

    private async Task TestDataAccessRepository()
    {
        var dataAccessRepository = new DataAccessRepository(() => new SqlConnection("connectionString")); // this should be handled by IoC
        var result = await dataAccessRepository.ExecuteQuery(reader =>
        {
            var name = (string) reader["name"];
            var address = (string) reader["address"];

            return (name, address);

        }, "select name, address from person where lastName like @lastName", ("@lastName", "Smith");
    }

About

Simple utility class to manage SQL connection and execution of SQL queries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages