Sivaji Tata

Sivaji Tata

  • NA
  • 159
  • 4.7k

SQL - Linq conversion

Feb 28 2021 5:19 AM

I have the following SQL query and I need to have it in LINQ, I tried several things but I can not get it working.

Here is the SQL query

  1. SELECT     ST.Description, ST.STId, COUNT(SI.SIId) AS Expr1  
  2. FROM         BP INNER JOIN  
  3.                       MbrBP ON BP.BPId = MbrBP.BPId INNER JOIN  
  4.                       SI ON BP.BPId = SI.BPId RIGHT OUTER JOIN  
  5.                       ST ON SI.STId = ST.STId  
  6. WHERE     (BP.CountryId = 1) AND (BP.RegionId = 1) AND (MbrBP.MemberId = 1)  
  7.       AND (SI.IsActive = 1)  
  8. GROUP BY ST.Description, ST.STId  
  9. UNION   
  10. SELECT      ST.Description, ST.STId, COUNT(SI.STId) AS Expr1  
  11. FROM         SI RIGHT OUTER JOIN  
  12.                       ST ON SI.STId = ST.STId  
  13. GROUP BY ST.Description, ST.STId  
 Thanks in advance.

Answers (1)