-2
select A.Name,B.UserId
from [dbo].[SentryBoxs] as A
left join [dbo].[SentryBoxUsers] as B on A.ID = B.SentryBoxId
and B.UserId = '970500c2-51bd-443e-ae10-585455f2b326'

[enter image description here][

enter image description here

How to implement by linq???

Nemus
  • 3,879
  • 12
  • 38
  • 57

1 Answers1

0
var ans = from A in dboSentryBoxs
          join B in dboSentryBoxUsers on new { A.ID, UserID = "970500c2-51bd-443e-ae10-585455f2b326" } equals new { ID = B.SentryBoxId, B.UserID } into Bjoin
          from B in Bjoin.DefaultIfEmpty()
          select new { A.Name, B.UserID };
NetMage
  • 26,163
  • 3
  • 34
  • 55