dictionary 添加数据

 
      

     var empList = from p in customers
                          select new
                          {
                              p.Personnel_ID,
                              p.PersonName
                          };
            var empTempList = empList.Distinct().ToList();
            Dictionary<string, string> dict = new Dictionary<string, string>();
            if (empTempList != null && empTempList.Count() > 0)
            {
                foreach (var item in empTempList)
                {
                    dict.Add(item.Personnel_ID, item.PersonName);
                }
            }
            ViewBag.EmpList = dict;

 

posted on 2016-07-01 11:17  DDLL11  阅读(982)  评论(0编辑  收藏  举报