I have a list of advanced ticket objects that has a structure like this:
AdvancedTicket
-Id
-BasicTicket
-CreatedDate
BasicTicket
-Id
And when I query my advanced ticket table I get this:
1, BasicTicketId1, 10/11/12
2, BasicTicketId2, 10/11/12
3, BasicTicketId1, 10/12/13
...
I want to be able to say "Give me all of the AdvancedTickets but only show me the most recent one for each advanced ticket".
I have this code that is not working:
from item in allAdvancedTickets
group item by item.BasicTicket.Id
into basicTicket
let d = basicTicket.OrderByDescending(c => c.CreatedDate)
orderby d descending
select basicTicket;
I am running into an error that says at least one item needs to implement iComparable.
I think this query is wrong to begin with but I have never used this function in linq before and I would appreciate some help.