I have to write a complex SQL Query using Entity Framework , but I can not figure out how to combine them , but at the same time to have a code with an optimal execution.
Here is my SQL Query:
Select DATEPART(HOUR,Datetime),AVG(temperature1),AVG(temperature2),AVG(humidity1),
from Table ,
where Day(Datetime)=@param,
group by DATEPART(HOUR,Datetime),
order by DATEPART(HOUR,Datetime);
And here is what I've tried using Entity Framework :
List<Greenhouse> greenhouse = context.Greenhouses
.Where(x => x.Datetime.Day == DtFrom.Day && x.Datetime.Month == DtFrom.Month && x.Datetime.Year == DtFrom.Year).ToList();
//.GroupBy(x => x.Datetime.Hour).ToList;
Can anyone help me with some ideas?Thanks.