protected IList <T> QueryObjects <T>(string query, JoinOn joinOn, params object[] arguments) { using (var conn = CreateOpenConnection()) using (var selectStatement = CreateCommand(conn, query, arguments)) using (var dataReader = selectStatement.ExecuteReader()) { var objects = new List <T>(); while (dataReader.Read()) { var obj = new ResultSetObjectMapper <T>(dataReader, joinOn).MapResultToType(); objects.Add(obj); } return(objects); } }
protected T QueryObject <T>(string query, JoinOn joinOn, params object[] arguments) { using (var conn = CreateOpenConnection()) using (var selectStatement = CreateCommand(conn, query, arguments)) using (var dataReader = selectStatement.ExecuteReader()) { if (dataReader.Read()) { return(new ResultSetObjectMapper <T>(dataReader, joinOn).MapResultToType()); } else { return(default(T)); } } }
public ResultSetObjectMapper(IDataReader dataReader, JoinOn joinOn, string columnPrefix = null) { this.dataReader = dataReader; this.joinOn = joinOn; this.columnPrefix = columnPrefix; }