Derived tables in Linq to SQL

2019-08-10 03:51发布

问题:

I would like to implement this in Linq to SQL:

select * from (
    select * from Orders) as A

Obviously this is a pointless example, but I just can't figure out how to do it!

回答1:

Try something like this:

var subquery = from row in Orders select row;
var query = from row in subquery select row;


回答2:

using (var dc = new NorthwindDataContext())
{
             var A = from ordOuter in
                 from ordInner in dc.Orders
                 select ordInner
             select ordOuter;
}