我正在尝试使用基于 ID(GUID)的 linq 进行集合。使用字典时出现错误“已添加具有相同键的项目”有什么建议吗?
foreach (Guid i in ar)
{
var prod = (from r in datacontext.item_tables's where r.itemID == i select r);
Dictionary<Guid, item_tables> tempdata =prod.ToDictionary(s => s.itemID);
Facet[] ftemp = new Facet[tempdata.Count];
string s1 = "";
ftemp[0] = new Facet("descriptiob", FacetType.Text, tempdata[i].Description);
ftemp[1] = new Facet("date", FacetType.Text, tempdata[i].uploaddate);
for (int iv = 0; iv < tempdata.Count; iv++)
{
s1 += tempdata[i].ProductName + " \n";
}
ftemp[2] = new Facet("ProductName", FacetType.Text, s1);
}