我在 SQL 中有这个查询
SELECT DISTINCT '20' + Left(charWeekNo ,2) AS title, COUNT('') AS colspan
FROM Table1 PWeek
GROUP BY Left(charWeekNo ,2)
如何使用上述查询在 linq 中编写?
我在 SQL 中有这个查询
SELECT DISTINCT '20' + Left(charWeekNo ,2) AS title, COUNT('') AS colspan
FROM Table1 PWeek
GROUP BY Left(charWeekNo ,2)
如何使用上述查询在 linq 中编写?
var PWeek = Table1
.GroupBy(x=>x.charWeekNo.Substring(0,2))
.Select(x=>new{title = "20" + x.Key, colspan = x.Count()})
var result =Table1.GroupBy(x=>x.charWeekNo.Substring(0,2))
.Select(g=>new {title = "20" +g.Key, colspan =g.Count()}).ToList()