c# - How to write a lambda expression to create a burndown chart -
my goal create burndown chart.
i have fault object following relevant fields:
- faultid
- faultcreationstartdate
- faultcloseddate
i have create list returns list of day between 2 given dates
list<datetime> listofdays = new list<datetime>(); int lastdayofmonth = datetime.daysinmonth(i_date.year, i_date.month); (int = 1; <= lastdayofmonth; i++) { listofdays.add(new datetime(datetime.now.year, datetime.now.month, i)); }
now want in each day number of faults open, it's means haven't been closed.
basically faultcloseddate
should > relevant day
i have created linq expression doin inner join , not left join.
i want days in month , count opened faults in day
var tryfaults = listofdays.selectmany(d => i_context.faults.getallfaults() .where(f=> f.faultclosedatetime >= d.date), (d, f) => new { date = d.date, open = f.faultid }).groupby(d => d.date).select(d => new { date = d.key.date, open = d.count() }).tolist();
you can use that:
var allfaults = i_context.faults.getallfaults(); var faults = listofdays.select(d => new { day = d.date, openfaults = allfaults.count(f => f.faultclosedatetime >= d.date) });
Comments
Post a Comment