[英]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. 我有一个名为M1的主表,它由三个单独的表T1,T2和T3组成。
I need to join 3 tables onto M1 using their Ids and display their Names For this I am using the following query: 我需要使用他们的ID将3个表连接到M1并显示他们的名称为此我使用以下查询:
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
" 我使用过这种方式,但是我收到一条错误,指出“ Type inference failed in call to Join
”
Could any one please tell me where I went wrong? 有谁可以告诉我哪里出错了?
请检查列的数据类型以避免“调用加入时类型推断失败”异常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.