/// <summary> /// 查询 /// </summary> /// <returns></returns> public DbArray Query(string sql, params object[] args) { var list = new DbArray(); this.Open(); using (DbCommand cmd = _conn.CreateCommand()) { cmd.CommandText = sql; cmd.Transaction = _tran; AddDbParameter(cmd, args); using (DbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { DbObject obj = new DbObject(); for (var i = 0; i < dr.FieldCount; i++) { obj.Add(dr.GetName(i), dr.GetValue(i)); } list.Add(obj); } dr.Close(); } } return(list); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <returns></returns> public DbArray GetArray(string name) { if (this[name] is DbArray) { return((DbArray)this[name]); } var jArr = this[name] as Newtonsoft.Json.Linq.JArray; if (jArr == null) { return(null); } DbArray arr = new DbArray(); foreach (Newtonsoft.Json.Linq.JObject obj in jArr) { arr.Add((DbObject)obj.ToObject(typeof(DbObject))); } return(arr); }
/// <summary> /// /// </summary> /// <param name="total"></param> /// <param name="data"></param> public DbPagingResult(long total, DbArray data) { this.total = total; this.data = data; }