Help me convert SQL to LINQ

I have this query that I was trying to figure out how to convert to LINQ:

select bjbecd, bjbesk, areotx 
from insku 
inner join iniwre on bjcomp=a7comp and bjbecd=a7becd and bjbesk=a7besk 
inner join initem on bjcomp=arcomp and bjbecd=arbecd 
where a7comp=1 and 
a7wcde in (1,10) and 
a7ohdq>0 and rtrim(a7becd) + rtrim(a7besk) not in
(select skucode from eoditems)

And here is my LINQ:

(from i in db.INSKUs
    join w in db.INIWREs on 
        new { i.BJCOMP, i.BJBECD, i.BJBESK }
        equals  
        new { w.A7COMP, w.A7BECD, w.A7BESK } 
    join t in db.INITEMs on 
        new { i.BJCOMP, i.BJBECD }
        equals 
        new { t.ARCOMP, t.ARBECD }
    where w.A7COMP == 1
    where w.A7WCDE == 1 || w.A7WCDE == 10
    where w.A7OHDQ > 0
    where !(from z in db.EODItems
            select z.SkuCode).Contains(w.A7BECD.TrimEnd() + w.A7BESK.TrimEnd())
    select new { i.BJBECD, i.BJBESK, t.AREOTX }
);

I get an error in the first statement, which says: "The type of one of the expressions in the join clause is incorrect. Type input error in the" Join "call."

All the requests I made related to type matching errors, but I checked all my types four times inside the joins, and they are the same.

+5
source share
1 answer

Try to do something like this:

join w in db.INIWREs on 
 new { i.BJCOMP, i.BJBECD, i.BJBESK }
    equals  
       new { BJCOMP = w.A7COMP, BJBECD = w.A7BECD, BJBESK  = w.A7BESK } 

Must work.

+5
source

All Articles