0

我在 SQL 中有这个查询

SELECT   DISTINCT '20' + Left(charWeekNo ,2) AS title, COUNT('') AS colspan
FROM Table1 PWeek  
GROUP BY Left(charWeekNo ,2)

如何使用上述查询在 linq 中编写?

4

2 回答 2

1
var PWeek = Table1
    .GroupBy(x=>x.charWeekNo.Substring(0,2))
    .Select(x=>new{title = "20" + x.Key, colspan = x.Count()})
于 2013-09-17T06:54:43.147 回答
0
var result  =Table1.GroupBy(x=>x.charWeekNo.Substring(0,2))
               .Select(g=>new {title = "20" +g.Key, colspan =g.Count()}).ToList()
于 2013-09-17T06:56:14.977 回答