开发者

How to get data from 2 tables without joining them?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜