static List <object> QueryData(string key, Type type, string query, IEnumerable <Attribute.FieldMapping> mapping, DBHelper helper) { if (cacheDatas.Count > 1000) { EventLog.Log("数据缓存超过了1000个,请检查程序调用是否正确", true); } DateTime time = DateTime.Now; System.Data.Common.DbDataReader reader; string sql; //语句 if (query.IndexOf("select ") > -1) { sql = query; reader = helper.ExecDataReader(sql); }//存储过程 else if (query.IndexOf("exec ") > -1) { string sp = query.Replace("exec ", ""); reader = helper.RunDataReader(sp); }//表名 else { sql = "select * from " + query; reader = helper.ExecDataReader(sql); } double runTime; var list = ObjectConvert.DataReaderToObjectList(reader, type, mapping, out runTime); //var queryInfo = new LambdaQuery.Mapping.QueryInfo<object>(false, mapping); //var list = ObjectConvert.DataReaderToIModelList2<object>(reader, queryInfo); string par = ""; foreach (KeyValuePair <string, object> item in helper.Params) { par += item.Key + ":" + item.Value; } //list.ForEach(b => // { // var item = b as IModel; // item.AddCacheListen(); // }); var ts = DateTime.Now - time; //WriteLog("更新查询 " + tableName + " 参数 " + par); EventLog.Log("更新查询 " + key + " 用时:" + ts.TotalSeconds + "秒", "DataCache"); return(list); }