I’m trying to create a grouped ListView for a Windows 8 Metro style app. Linq is a bit new to me. I understand the basics and I’m familiar with mySQL but I’m struggling with the syntax of this one.
I have a class that contains (amongst other things) a string “Date” and an int “epochTime”. The date string is a representation of the epochTime but in the format “April, 23rd 2012” for example – ignoring the hour of the event.
So I want to group by the date string and sort the groups and the contents of the groups by the epoch time. The closest I’ve come so far is this
var result =
from fixture in items
group fixture by new { fixture.Date, fixture.epochTime } into g
orderby g.Key.epochTime
select g;
But this groups on date and epochTime so I get events that are on the same day but a different time in groups of their own. Can anyone point me in the right direction?
Thanks is advance
Well it may not be guaranteed by linq butyou could try ordering the list before grouping:EDIT According to MSDN the order is preserved after grouping: