views:

69

answers:

2

Possible Duplicate:
Why did the following linq to sql query generate a subquery?

I have a qs. for you LINQ gurus...

I am using LINQ in a composable way and the SQL being generated is a bit complex and of the form:

SELECT xxx FROM
(
   SELECT yyy from myTable1, myTable2
   WHERE foo == bar
) AS t7
WHERE t7.column == value.

The LINQ statement is formed by combining a few IQueryable types, whereby the SELECT part is in a method that returns an IQuerable and then I tack on some conditions elsewhere.

I know it is in the way I compose the LINQ that I need to tweak, but I want to finally execute SQL:

SELECT xxx FROM myTable1, myTable2
   WHERE foo == bar
and t7.column == value.

So, basically the nested FROM clause goes away.

This seems to be a standard problem, and I can provide more details of my LINQ statements, if needed.

A: 

If you don't like the SQL generated by LINQ to SQL use something like the IQToolkit and generate the SQL you do want.

Firestrand