I need to write on linq2sql analogue of the following query:
SELECT A.Field1开发者_如何学JAVA, B.Field2 FROM tableA A, tableB B
How can I do that?
I would start from something like this
from a in DBContext.tableA,
...
select new {Field1=a.Field1, Field2=b.Field2};
but what should I write instead of "..."? How to mention 2nd table to be linked?
Thanks.
P.S. Hope I am clear
To cross join, try
from a in DBContext.tableA
from b in DBContext.tableB
select new {Field1=a.Field1, Field2=b.Field2};
If you select data from two tables without joining them, you will get a cross join, which is every row in the first table joined with every row in the second table. This is probably not what you want.
精彩评论