有人可以帮我将以下SQL查询转换为LINQ吗?
select
convert(varchar(10),date,110) as 'Date',
max(users) as 'Maximum Number of Users',
max(transactions) as 'Maximum Number of Transactions'
from
stats
where
datepart(Year, Date) = '2010'
group by
convert(varchar(10),date,110)
order by
convert(varchar(10),date,110)
提前谢谢!
答案 0 :(得分:0)
很难从您提供的有限信息中辨别出来,但这可能会起到作用:
var results = from stat in db.Stats
group stat by stat.Date.Date into statGroup
orderby statGroup.Key
select new
{
Date = statGroup.Key,
MaximumNumberOfUsers = statGroup.Max(c => c.Users),
MaximumNumberOfTransactions = statGroup.Max(c => c.Transactions)
};