public static List <T> ToList <T>(this IDbConnection connection, string commandText) { using (var command = connection.CreateCommand(commandText)) using (ConnectionOpener.Open(connection)) { return(command.ToList <T>()); } }
public void MaybeDoesSomething_WithGoodNames() { // Setup var csBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder() { IntegratedSecurity = true, DataSource = "AppDvSqlLi1", InitialCatalog = "brett_data" }; List <CollegeWithGoodNames> collegeList; using (var connection = new System.Data.SqlClient.SqlConnection(csBuilder.ConnectionString)) using (ConnectionOpener.Open(connection)) using (var command = connection.CreateCommand("SELECT * FROM college")) { // Act collegeList = command.ToList <CollegeWithGoodNames>(); } // Verify Assert.IsTrue(collegeList.Count > 0); }