I have to select and group by because I need to get the average and sum of some items, my problem is first of all the group by is based on month(m_date.Month) so inside the group by I don't have access to year anymore, my second problem is what if I want to have other properties from statisticsDaily class in my query? with this query I only have access to grouped by fields, look at below:
var rslt = await (from d in db.statMonth.Include(f=>f.MasterData).Where(d=>d.m_turbine_id == IPAddress.Parse(id) && d.m_date >= frm)
group d by d.m_date.Month into g
select new statisticsDaily
{
Date = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(g.Key),
Production = g.Sum(s => s.m_energy_prod),
m_wind_speed = g.Average(s => s.m_wind_speed),
Availability = g.Average(s => s.m_availability),
}
).OrderBy(s=>s.Date).ToListAsync();
my statsticDaily class is :
public class statisticsDaily
{
public string Date { get; set; }
public Nullable<float> Production { get; set; }
public Nullable<float> m_wind_speed { get; set; }
public Nullable<float> Availability { get; set; }
public string Comments { get; set; }
public string TurbineId { get; set; }
public string Countries { get; set; }
}