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;