Commits

Inside Zhou  committed 22f3b55

[bugfix]QueryPlan在解析结果集的过程中,进行列遍历时,QueryPlan的索引计算错误。

  • Participants
  • Parent commits 6045fc3

Comments (0)

Files changed (2)

 		#region ICollection<KeyValuePair<string,object>> 成员
 
 		void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item) {
-			throw new NotImplementedException();
+			this._dict.Add(item);
 		}
 
 		void ICollection<KeyValuePair<string, object>>.Clear() {
-			throw new NotImplementedException();
+			this._dict.Clear();
 		}
 
 		bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item) {
-			throw new NotImplementedException();
+			return this._dict.Contains(item);
 		}
 
 		void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex) {
-			throw new NotImplementedException();
+			this._dict.CopyTo(array, arrayIndex);
 		}
 
 		int ICollection<KeyValuePair<string, object>>.Count {
-			get { throw new NotImplementedException(); }
+			get { return this._dict.Count; }
 		}
 
 		bool ICollection<KeyValuePair<string, object>>.IsReadOnly {
-			get { throw new NotImplementedException(); }
+			get { return this._dict.IsReadOnly; }
 		}
 
 		bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item) {
-			throw new NotImplementedException();
+			return this._dict.Remove(item);
 		}
 
 		#endregion

File Sql/QueryPlan.cs

 			var dt = this.GetDataTable();
 
 			return dt.ToDynamicObjects((dr) => {
-				var dy_row = _ParseQueryResult(dr, this);
-				return dy_row;
+				var dyRow = _ParseQueryResult(dr, this).payload;
+				return null == this.RowHandler ? dyRow : this.RowHandler(dyRow);
 			});
 		}
 
 
 		//参数guid由父级传递进来,用于判断当前被join的对象是否应为DBNull.Value。
 		static dynamic _ParseQueryResult(DataRow dr, QueryPlan queryPlan, int qpCount = 0, string guid = null) {
-			dynamic result = new DyObj();
+			dynamic payload = new DyObj();
 			var tbAlias = _GenerateQueryPlanAlias(queryPlan, qpCount);
 
 			foreach(var kv in queryPlan._column) {
 				var colName = "{0}_{1}".Fmt(tbAlias, string.IsNullOrEmpty(c.alias) ? c.attr_name as string : (c.alias as string).Substr());
 				if(ObjectHelper.IsNil(c["join"])) {
 					if(!string.IsNullOrEmpty(guid) && c._guid == guid && ObjectHelper.IsNil(dr[colName])) {
-						return null;
+						dynamic r = new DyObj();
+						r.query_plan_count = qpCount;
+						r.payload = null;
+						return r;
 					}
-					result[c.attr_name] = dr[colName] is DBNull ? null : dr[colName];
+					payload[c.attr_name] = dr[colName] is DBNull ? null : dr[colName];
 				}
 				else {
-					result[c.attr_name] = _ParseQueryResult(dr, c.join.plan, ++qpCount, c.join.column._guid);
+					var parsedJoinColumnResult = _ParseQueryResult(dr, c.join.plan, ++qpCount, c.join.column._guid);
+					qpCount = parsedJoinColumnResult.query_plan_count;
+					payload[c.attr_name] = parsedJoinColumnResult.payload;
 				}
 
 				if(dr.Table.Columns.Contains(Rownum)) {
-					result[Rownum] = dr[Rownum];
+					payload[Rownum] = dr[Rownum];
 				}
 			}
 
-			return null == queryPlan.RowHandler ? result : queryPlan.RowHandler(result);
+			dynamic result = new DyObj();
+			result.query_plan_count = qpCount;
+			result.payload = payload;
+			return result;
 		}
 	}