简体   繁体   中英

linq query to join 3 tables onto one table

I have a main table called M1 which consists of Ids of three individual tables T1,T2 and T3.

I need to join 3 tables onto M1 using their Ids and display their Names For this I am using the following query:

 var query= (from i in dbContext.M1
             join j in dbContext.T1 on i.Mt1_id  equals j.Mt1_id
             join l in dbContext.T2 on i.Mt2_id equals l.Mt2_id
             join s in dbContext.T3 on i.Mt3_id equals s.Mt3_id
             where i.Mid >= 1
             select new
             {
               a=j.name,
               b=l.name,
               c=s.name
             }).ToArray();

I have used this way, but I am getting an error stating that " Type inference failed in call to Join "

Could any one please tell me where I went wrong?

请检查列的数据类型以避免“调用加入时类型推断失败”异常

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM