I have trouble making joins. Overall query is going to be huge, but basicly, user inputs 1 ID, and data for report is going to be populated from database.
There can be one to many relationship. I made ... join oneToManyTable_ in db.tableA on ID equals oneToManyTable_.DeviceId into oneToManyTable
. This expression returns IEnumerable. Trouble now - each of those entities I have to join more tables. How do I do that? If i write ... join anotherTable in db.tableB on oneToManyTable.ID equals anotherTable.ID into oneToManyTable
, it yells to me, that oneToManyTable is IEnumerable. Hope you could understand my trouble.
It was easier if you could have been more specific. Anyway, I think your problem is that you don't use select
after your first join. The format should be like this:
var output =
from class1 in context.Table1
join class2 in context.Table2
on class1.ID equals class2.DeviceID
select new { Class1 = class1, Class2 = class2 } into firstJoin
join class3 in context.Table3
on firstJoin.Class1.ID equals class3.ID
select new { firstJoin, Class3 = class3 }
This will join your three classes on their ID and also give you all their properties in output.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.