示例#1
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);
             }
 }
示例#2
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());
                 }
                 else
                 {
                     return(default(T));
                 }
             }
 }
示例#3
0
 public ResultSetObjectMapper(IDataReader dataReader, JoinOn joinOn, string columnPrefix = null)
 {
     this.dataReader   = dataReader;
     this.joinOn       = joinOn;
     this.columnPrefix = columnPrefix;
 }