-4

次の sql ステートメントは問題なく動作しますが、どうすれば linq (VB) に変換できますか?

私はいくつかのオンラインツールを探していましたが、うまくいきません...

ありがとう

SELECT distinct a.sid, a.DisplayName, 
    CASE WHEN b.sID IS NOT NULL THEN 1 ELSE 0 END AS Type1,
    CASE WHEN c.sID IS NOT NULL THEN 1 ELSE 0 END AS Type2,
    CASE WHEN d.sID IS NOT NULL THEN 1 ELSE 0 END AS Type3
FROM dbo.vHRIS_EmailAlert a
LEFT JOIN dbo.vHRIS_EmailAlert b ON a.sid = b.sid AND b.Type = 4
LEFT JOIN dbo.vHRIS_EmailAlert c ON a.sid = c.sid AND c.Type = 5
LEFT JOIN dbo.vHRIS_EmailAlert d ON a.sid = d.sid AND d.Type = 6

where a.CID=37
and (b.Type=4 or c.Type=5 or d.Type=6) 

以下は私のlinqです。LINQPad で linq を実行すると、「構文エラー」が返されます

(From a In db.vHRIS_EmailAlerts _
Group Join b In db.vHRIS_EmailAlerts _
      On New With { a.SID, .Type = 4 } _
  Equals New With { b.SID, .Type = CType(CLng(b.Type),Int64?) } Into b_join = Group _
From b In b_join.DefaultIfEmpty() _
Group Join c In db.vHRIS_EmailAlerts _
      On New With { a.SID, .Type = 5 } _
  Equals New With { c.SID, .Type = CType(CLng(c.Type),Int64?) } Into c_join = Group _
From c In c_join.DefaultIfEmpty() _
Group Join d In db.vHRIS_EmailAlerts _
      On New With { a.SID, .Type = 6 } _
  Equals New With { d.SID, .Type = CType(CLng(d.Type),Int64?) } Into d_join = Group _
From d In d_join.DefaultIfEmpty() _
Where _
  CLng(a.CID) = 37 And _
  (CLng(b.Type) = 4 Or _
  CLng(c.Type) = 5 Or _
  CLng(d.Type) = 6) _
Select  _
  SID = CType(a.SID,Int32?), _
  a.DisplayName, _
  Type1 = If( _
  Not b.SID Is Nothing, 1, 0), _
  Type2 = If( _
  Not c.SID Is Nothing, 1, 0), _
  Type3 = If( _
  Not d.SID Is Nothing, 1, 0)) _
).Distinct.ToList
4

1 に答える 1