Today something strange happened when I was sorting a list using Linq + lambda. I have a list with articles that should be OrderedByDescending on a Field c => c.Statistics.Created. This field comes back as a DateTime. I do the following:
newsItems = newsItems.OrderByDescending(c => c.Statistics.Created).ToArray<Item>();
I understand that this list will be ordered in a descending direction and that the time of this date is also being watched as this is just a DateTime object. Now the weird part. I adjust the code to look the following:
newsItems = newsItems.OrderByDescending(c => c.Statistics.Created.Date).ToArray<Item>();
Now when I look at the list, the items are still ordered the way they should be. I can't understand why the list is still ordered the right way, when I tell Linq to only look at the date. Somehow Linq decides to look at the time aswell. When I attach my application to the w3p process and watch what happens I see that the Time is actually empty on the Date object, like I expect. Can someone explain me how this list actually is getting sorted on time when I tell linq to only look at the date?
I have already found what made this strange behavior occur. It was that the list (gotten out of a CMS) was already ordered some way. When I then sorted on the date (with no time) the order was apperently correct an Linq did no do anything else with this date.</div