You could do this:
var query= from t1 in context.MY_TEST_TABLE1
from t2 in context.MY_TEST_TABLE2
where t1.firstname == t2.name
select new { Table1Id= t1.ID, FirstName= t1.firstname, Table2Id=t2.ID,Name= t2.name};
Another way to do a cross join in Linq to Entities is using SelectMany extension method:
var query= context.MY_TEST_TABLE1.SelectMany(
t1=>context.MY_TEST_TABLE2
.Where(t2=>t1.firstname == t2.name)
.Select(t2=>new {
Table1Id= t1.ID,
FirstName= t1.firstname,
Table2Id=t2.ID,
Name= t2.name
})
);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…