0

我需要将此 SQL 转换为 Linq 以与实体框架一起使用:

SELECT TheDate, COUNT(DISTINCT IPAddress) as Count 
FROM TheTable Group By TheDate
Order By TheDate

困难在于计数(不同的 IP 地址)。

格雷格

4

1 回答 1

1
from x in db.TheTable
group x by x.TheDate into g
orderby g.Key
select new
{
    TheDate = g.Key,
    DistinctIPCount = g.Select(x => x.IPAddress).Distinct().Count()
}
于 2013-09-18T18:17:36.143 回答