2011-06-24 158 views
1

如何將其轉換爲Linq?SQL TO LINQ-轉換

SELECT 
     ps.forename,Count(ps.Forename) 

FROM 
     [Dbase].[dbo].[Absence] ab 
INNER JOIN 
     [Dbase].[dbo].[Person] ps 
On 
ab.empid=ps.id 
where ps.forename='hari' 
GROUP BY ps.forename 
Having Count(ps.forename)>2 

回答

1

在這裏你去。

  var result = (from x in Absence 
        join y in Person on x.empid equals ps.id 
        group x by new { z = ps.forename == "hari" } into g 
        where g.Count() > 2 
        select new 
        { 
         g.Key, 
         cnt = g.Count() 
        });