/// <summary> /// maq 执行返回 List<Dictionary<string, object>> /// </summary> public static List <Dictionary <string, object> > Query(string name, DbParameter[] param, DataContext db = null, string key = null, bool isOutSql = false) { key = key == null?MapDb(name) : key; var config = db == null?DataConfig.Get(key) : db.config; if (config.IsUpdateCache) { InstanceMap(key); } if (DbCache.Exists(config.CacheType, name.ToLower())) { var sql = MapXml.GetMapSql(name, ref param, db, key); isOutSql = isOutSql ? isOutSql : IsMapLog(name); BaseAop.AopMapBefore(name, sql, param, config, AopType.Map_List_Dic); var result = FastRead.ExecuteSql(sql, param, db, key, isOutSql, false); if (MapXml.MapIsForEach(name, config)) { if (db == null) { using (var tempDb = new DataContext(key)) { for (var i = 1; i <= MapXml.MapForEachCount(name, config); i++) { result = MapXml.MapForEach(result, name, tempDb, key, config, i); } } } else { result = MapXml.MapForEach(result, name, db, key, config); } } BaseAop.AopMapAfter(name, sql, param, config, AopType.Map_List_Dic, result); return(result); } else { BaseAop.AopMapBefore(name, "", param, config, AopType.Map_List_Dic); var data = new List <Dictionary <string, object> >(); BaseAop.AopMapAfter(name, "", param, config, AopType.Map_List_Dic, data); return(data); } }
/// <summary> /// maq 执行返回 List<Dictionary<string, object>> /// </summary> public static List <Dictionary <string, object> > Query(string name, DbParameter[] param, DataContext db = null, string key = null) { key = key == null?MapDb(name) : key; var config = db == null?DataConfig.Get(key) : db.config; if (config.IsUpdateCache) { InstanceMap(key); } if (DbCache.Exists(config.CacheType, name.ToLower())) { var sql = MapXml.GetMapSql(name, ref param, db, key); var result = FastRead.ExecuteSql(sql, param, db, key); if (MapXml.MapIsForEach(name, config)) { if (db == null) { using (var tempDb = new DataContext(key)) { for (var i = 1; i <= MapXml.MapForEachCount(name, config); i++) { result = MapXml.MapForEach(result, name, tempDb, key, config, i); } } } else { result = MapXml.MapForEach(result, name, db, key, config); } } return(result); } else { return(new List <Dictionary <string, object> >()); } }