Beispiel #1
0
 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());
                 }
                 return(default);
Beispiel #2
0
 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);
             }
 }
 public ResultSetObjectMapper(IDataReader dataReader, JoinOn joinOn, string columnPrefix = null)
 {
     this._dataReader   = dataReader;
     this._joinOn       = joinOn;
     this._columnPrefix = columnPrefix;
 }