I have four entities and I need to join them. Is it possible to join more than two entities?
Asked
Active
Viewed 554 times
2 Answers
0
The good LINQ approach is that you should avoid JOIN as much as possbile. If you entities are property connected, you should be able to query related entities without "JOIN", that is the beauty of LINQ.

J.W.
- 17,991
- 7
- 43
- 76
-
why will join causes performance drawbacks? – John John Jan 04 '13 at 15:47
-
1I didn't say performance drawbacks, I just say you should be able to query multiple entities without JOIN. – J.W. Jan 04 '13 at 15:48
-
Indeed you should be able to in an ideal world... but alas with legacy systems the world is rarely ideal. – Paul Zahra Jul 12 '14 at 12:27
0
Yes it is possible to join more than two entities, although it starts getting messy and the resulting SQL isn't pretty... have a read of this SO post for an example and another example here in this SO post
P.S. As J.W. implies, if the database uses foreign keys etc correctly / fully then JOINs are not necessary.
and different types of joins other than the simple inner join can become nasty... Left Outer Joins being a pain... see here

Community
- 1
- 1

Paul Zahra
- 9,522
- 8
- 54
- 76