标签:dict logs ram 类型转换 foreach collect instance info 转换
x
#region 博客Code {DBEntities}生成EFModel的时候自己命名的 using ({DBEntities} db = new { DBEntities }()) { var que = (from c in db.CollectItem select c).ToList(); List<Dictionary<string, object>> retList = new List<Dictionary<string, object>>(); Dictionary<string, object> retDic = new Dictionary<string, object>(); PropertyInfo[] properArr = null; foreach (var q in que) { retDic = new Dictionary<string, object>(); properArr = q.GetType().GetProperties(); foreach (PropertyInfo p_info in properArr) { retDic.Add(p_info.Name, p_info.GetValue(q)); } retList.Add(retDic); } Dictionary<string, string> resultDic = new Dictionary<string, string>(); resultDic.Add("ret", "1"); JSONParameters jp = new JSONParameters { UseUTCDateTime = false }; resultDic.Add("list", JSON.Instance.ToJSON(retList, jp)); return JSON.Instance.ToJSON(resultDic, jp); } #endregion
x
EF将IEnumerable<T>类型转换为Dictionary<T,T>类型
标签:dict logs ram 类型转换 foreach collect instance info 转换
原文地址:http://www.cnblogs.com/love-zf/p/6438339.html