简体   繁体   English

对in使用多个LINQ语句,以使左外部联接的DefaultIfEmpty()不起作用

[英]Using multiple LINQ statements with into , for the DefaultIfEmpty() of the left outer join not working

I am trying to use the "into" statement with DefaultIfEmpty() for the left outer join, but when I try to join to the 3rd collection, it doesn't like it (can't see /use it / find it ) 我正在尝试将DefaultInEmpty()的“ into”语句用于左外部连接,但是当我尝试连接到第三个集合时,它不喜欢它(看不到/使用它/找到它)

It doesn't seem to like personRole on the line below 在下一行似乎不喜欢personRole

join roleTypes in roles on personRole.ContactRoleTypeId equals roleTypes.ContactRoleTypeId into r2

the query: 查询:

findPersonResultsViewModelNew =
         from azed in findPersonViewModel.findPersonResultsViewModel
         join personRole in personContactRoles on azed.PersonID equals personRole.PersonId into r1
         join roleTypes in roles on personRole.ContactRoleTypeId equals roleTypes.ContactRoleTypeId into r2
         from p in r1.DefaultIfEmpty()
         from g in r2.DefaultIfEmpty()
         select
         //…. other code 

Change the order of your statements. 更改语句的顺序。 When doing left join, you must immediately follow the join with a new from ... DefaultIfEmpty() : 在进行左联接时,必须立即在join添加一个新from ... DefaultIfEmpty()

findPersonResultsViewModelNew =
         from azed in findPersonViewModel.findPersonResultsViewModel
         join personRole in personContactRoles on azed.PersonID equals personRole.PersonId into prj
         from personRole in prj.DefaultIfEmpty()
         join roleTypes in roles on personRole.ContactRoleTypeId equals roleTypes.ContactRoleTypeId into rtj
         from roleTypes in rtj.DefaultIfEmpty()
         select

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM