c# - How to solve date group by in Data Table -


hi can able result datatable wcf(api) , bind grid like:

datatable dt

     eventstart               |   eventend           =============================================   1/9/2015 1:00:00 pm      |   1/9/2015 1:15:00 pm    1/9/2015 3:00:00 pm      |   1/9/2015 4:15:00 pm    13/10/2015 10:00:00   |   13/10/2015 11:15:00    13/10/2015 1:00:00 pm    |   13/10/2015 2:15:00 pm  

but want result in datatable dt2 this

   date                     |  total minutes ==============================================   1/9/2015                  |  150 minutes   13/10/2015                |  150 minutes 

anybody can please.... new in linq....

skip datatables, , bind directly linq result, this:

grid.datasource=result   .groupby(x=>x.eventstart.date,x=>(x.eventend-x.eventstart).totalminutes)   .select(x=>new {date=x.key,totalminutes=x.sum()}); 

this assumes wcf returns ienumerable, has eventstart , eventend (like array, list, ilist, collection, etc)


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -