The examples given are designed to demonstrate (and test) usage in a variety of
settings. They are not necessarily the simplest, or most efficient, way to achieve
the desired result set. Think of them as an API usage guide, not as design guidelines.
Most SubQueries can be re-written as Joins, and most Joins can be re-written as
SubQueries. If, while coding, you are having trouble conceptualizing one approach,
then try the other. Technically, a JOIN's ON clause can take almost any where_condition,
and EntitySpaces supports many of these, including SubQueries. But, we agree with
most authorities on the subject, that the ON clause should be reserved for the conditions
that relate the two tables. All other conditional statements should be placed in
a WHERE clause. Typically, the ON clause only contains a column from each table
and a comparison operator. For example, take the Join(query).On(SubQuery) example
above. The much simpler query below returns the same result set. Its Where() clause
not only simplifies the On() clause, but eliminates the SubQuery completely.
C#
VB