我需要将此SQL转换为Linq以与Entity Framework一起使用:
SELECT TheDate, COUNT(DISTINCT IPAddress) as Count
FROM TheTable Group By TheDate
Order By TheDate
困难是Count(Distinct IPAddress)。
格雷格
答案 0 :(得分: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()
}