linq-extensions

Will First() perform the OrderBy()?

Is there any difference in (asymptotic) performance between var a = Orders.OrderBy(order => order.Date).First() and var y = Orders.Where(order => order.Date == Orders.Min(x => x.Date)).ToList(); i.e. will First() perform the OrderBy()? I'm guessing no. MSDN says enumerating the collection via foreach och GetEnumerator does but the ...

Extending LINQ classes to my own partial classes in different namespaces?

I have a .dbml file which of course contains the auto-generated classes based on my tables. I would however, like to extend them to my own classes. Typically I design such that each of my tables get their own namespace in their own folder containing all of their associated dao and service classes. So if I am dealing with a page that onl...

performance of linq extension method ElementAt

Hi The MSDN library entry to Enumerable.ElementAt(TSource) Method says "If the type of source implements IList, that implementation is used to obtain the element at the specified index. Otherwise, this method obtains the specified element." Let's say we have following example: ICollection<int> col = new List<int>...

linq extension method to take elements from the end of the sequence

Hi There is the enumerable extension method Take<TSource>( IEnumerable<TSource> source, int count ) which takes the first count elements from the start. Is there a way to take the elements from the end? or even better a way to take the elements from an offset to the end? Thanks ...