可以用 into 语法,配合 DefaultIfEmpty() 方法加载右侧表中的空值。
例子:

var query =
    from r in db.Roles
    join sr in
        (
        from ss in db.StaffInRoles
where ss.StaffId == staffId
        select ss
        )
        on r.Id equals sr.RoleId
into x
from y in x.DefaultIfEmpty()
    select new RoleInfo
    {
        RoleId = r.Id,
        RoleName = r.Name,
        IsSet = y != null
    };

相关文章:

  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-10-21
  • 2022-01-15
  • 2021-10-16
  • 2021-05-24
猜你喜欢
  • 2022-12-23
  • 2022-01-04
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
相关资源
相似解决方案