views:

34

answers:

1

I have this linq query:

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;

that has this problem:

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

how can i do to solve it?

+5  A: 

The two types should be the same - which means they'll need the same property names as you're using anonymous types. Try this:

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;

That's assuming that s.ID and h.USR_UtentiReference have the same type, and settings.GruppoSegreteria and h.ID_Gruppo do likewise.

Jon Skeet