so let's say I have an IEnumerable dates and I want to get the dates within a range.
Is Linq and IOrderedEnumerable intelligent enough to realize the ability to choose faster algorithms given that the dates are now ordered.
So consider this:
IOrderedEnumerable<ObjectWith2DateTimes> orderedDates = dates.OrderBy(x => new Tuple(x.datetime1,x.datetime2));
...
this is called a bunch
...
DateTime afterDateTime = (some datetime)
DateTime beforeDateTime = (other datetime)
yield return orderedDates.Where(x => x.datetime1 >= afterDateTime && x.datetime2 <= beforeDateTime)
If isn't smart with this implementation, is there some other implementation that would make it smart?
No it's not smart enough to do that. Enumerable.Where<TSource> takes a Func<TSource, bool>, not an Expression<Func<TSource, bool>> like Queryable.Where<TSource>. So you could do it with an IQueryable, but you'd need a query provider that can do that. It's probably not worth the trouble.
However, something like this should do: