我有以下linq查询
var temp = (from p in db.BEM_EVT_FULL
where (p.date_reception > dt)
group p by p.mc_object into g
orderby g.Count() descending
select new StringIntType
{
str = g.Key,
nbr = g.Count()
}).Take(50).ToList();我不需要将结果转换为StringIntType,而是需要将Dictionary与int和string类型结合使用。
发布于 2015-04-16 07:06:07
你可以试试这样的方法:
var temp = (from p in db.BEM_EVT_FULL
where (p.date_reception > dt)
group p by p.mc_object into g
orderby g.Count() descending
select new
{
Key = g.Key,
Value = g.Count()
}).Take(50)
.ToDictionary(x=>x.Key, y=>y.Value);发布于 2015-04-16 07:08:11
看起来这个问题可能有一个答案:Convert Linq Query Result to Dictionary
基本上,用ToList代替ToDictionary
.ToDictionary( t => t.Key, t => t.Value);https://stackoverflow.com/questions/29667487
复制相似问题