SahithiPinisetty
SahithiPinisetty

Reputation: 207

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?

Upvotes: 4

Views: 2614

Answers (1)

Sunny
Sunny

Reputation: 3295

Please check Datatype of columns to avoid "Type inference failed in call to Join" exception

Upvotes: 1

Related Questions