gpt4 book ai didi

c# - linq连接错误

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

我有这个 linq 查询:

var segreterie = from s in db.USR_Utenti join h in db.USR_Accounts
on new {s.ID, settings.GruppoSegreteria}
equals new {h.USR_UtentiReference,h.ID_Gruppo} select s;

有这个问题:

The type of one of the expressions in the join clause is incorrect.  Type inference failed in the call to 'Join'.   

我该如何解决?

最佳答案

这两种类型应该相同——这意味着它们需要与您使用匿名类型相同的属性名称。试试这个:

var segreterie = from s in db.USR_Utenti join h in db.USR_Accounts
on new {s.ID, Groups = settings.GruppoSegreteria}
equals new {ID = h.USR_UtentiReference, Groups = h.ID_Gruppo}
select s;

假设 s.IDh.USR_UtentiReference 具有相同的类型,并且 settings.GruppoSegreteriah.ID_Gruppo 照样做。

关于c# - linq连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2478919/

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