I want to receive the newest item from a collection. Each item has an DateTime field (EditDate) and I do a little query like that.
var s = from l in OCollectionAgents
where l.IDOfVehicle == agent.IDOfVehicle
orderby
agent.EditDate ascending
select l;
After the query I do
agent.DetailInformationOfResults.NewestAgentEditDate = s.First().EditDate;
But no matter if is set the sort direction to ascending or descending I always get the same item. The oldest item.
I fixed the problem by doing
agent.DetailInformationOfResults.NewestAgentEditDate = s.Max(d => d.EditDate);
This is a solution but I still wonder why my query result does not change the sort direction.