0
            var z = from x in resp1.table1
                    join y in resp2.table2 on x.fields equals y.fields
                    select
                    new {y.fields, y.fields1, x.fields2, x.fields3, x.fields4};

And I want a new table so basically I want to join three or more tables but I dont know how

3
  • 1
    Are you having a problem with that linq query? Commented Sep 19, 2012 at 3:59
  • the Table 1 have the primary key of table2 and table3, and I want to have all the fields of table2 and table3. How should I do it? Commented Sep 19, 2012 at 4:05
  • No. but I dont know how to query three tables. As you can see in my code above it only have two tables. And I want to have to join three tables which is the table1 have the primary key of table2 and table3. Commented Sep 19, 2012 at 4:11

2 Answers 2

1
var z = from x in resp1.table1
        join y in resp2.table2 on x.fields equals y.fields
        join z in resp3.table3 on x.fields equals z.fields
        select
        new {y.fields, y.fields1, x.fields2, x.fields3, x.fields4, z.fields5, z.fields6};

And so on... But first check if you really need a triple join!

Sign up to request clarification or add additional context in comments.

2 Comments

Lastly how can I short it ascending using the table1 fields?
@Therence before the select line use orderby fieldName1, fieldName2 replacing the fieldNames with the proper ones.
0
var z = from x in resp1.table1
        join y in resp2.table2 on x.fields equals y.fields
        join z in resp3.table3 on x.fields equals z.fields
        select
        new {y.fields, y.fields1, x.fields2, x.fields3, x.fields4, z.fields5};

1 Comment

Lastly how can I short it ascending using the table1 fields?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.