-1
我想下面的查詢LINQ轉換,如何將此SQL查詢轉換爲LINQ?
SELECT AVG(currentvalue) AS ChartAvg,
CONVERT(varchar(10), ReceivedDate, 103) AS RecDate
FROM DatapointValues
WHERE (CONVERT(varchar(10), ReceivedDate, 103) = '21/04/2011')
GROUP BY CONVERT(varchar(10), ReceivedDate, 103)
我用下面的LINQ,但沒有工作,
from datapointvalues in db.DatapointValues
where
Convert.ToString(datapointvalues.ReceivedDate) == "21/04/2011"
group datapointvalues by new {
Column1 = Convert.ToString(datapointvalues.ReceivedDate)
} into g
select new {
ChartAvg = (System.Decimal?)g.Average(p => p.currentvalue),
g.Key.Column1
}