0
具有以下的LINQ流利表达重复结果如果我尝试将流利语翻译为linq q表达式,我已经重复了值,尽管我在groupBy中使用Country.ToUpper():使用的GroupBy LINQ查询表达但不使用流利语法
var query = (from t in trains
group t by new {Country = t.Country.ToUpper(), t.Carriages}
into g
select new
{
Country = g.Key.Country,
TotalCarriage = g.Key.Carriages.Count,
SumCarriage = g.Key.Carriages.Sum(c => c.Length)
}).ToList();
我无法解释为什么发生这种情况。