我有这个 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.ID
和 h.USR_UtentiReference
具有相同的类型,并且 settings.GruppoSegreteria
和 h.ID_Gruppo
照样做。
关于c# - linq连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2478919/