Search code examples
.netsqllinq-to-sql

How to get data from 2 tables without joining them?


I need to write on linq2sql analogue of the following query:

SELECT A.Field1, 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


Solution

  • To cross join, try

    from a in DBContext.tableA
    from b in DBContext.tableB
    select new {Field1=a.Field1, Field2=b.Field2};