gpt4 book ai didi

c# - Linq 查询字典抛出 System.ArgumentException : An item with the same key has already been added

转载 作者:太空宇宙 更新时间:2023-11-03 17:32:17 24 4
gpt4 key购买 nike

<分区>

我有以下 LINQ 查询,我正在使用它来查询数据表和填充字典,但它不断抛出错误:

System.ArgumentException: An item with the same key has already been added.

我是 LINQ 的新手,想不出正确的写法。

有人可以帮忙吗?

var neworderGroupDict = (from m in KMVData.AsEnumerable()
select new
{
datakey = m.Field<string>("OrderNumber"),
datavalue = m.Field<int>("OrderGroup")
}).Distinct().ToDictionary(n => n.datakey, n => n.datavalue);

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com