Will First() perform the OrderBy()?
Posted
by Martin
on Stack Overflow
See other posts from Stack Overflow
or by Martin
Published on 2010-03-16T14:15:10Z
Indexed on
2010/03/16
14:26 UTC
Read the original article
Hit count: 198
linq-extensions
|LINQ
Is there any difference in (asymptotic) performance between
Orders.OrderBy(order => order.Date).First()
and
Orders.Where(order => order.Date == Orders.Max(x => x.Date));
i.e. will First() perform the OrderBy()? I'm guessing no. MSDN says enumerating the collection via foreach och GetEnumerator does but the phrasing does not exclude other extensions.
© Stack Overflow or respective owner