LINQ to objects performance

I am constructing a LINQ query on a DataSet, it will have a .Where condition, .Distinct and .OrderBy. I was thinking of doing this manually at first, at best I can probably manage this in two loops. Which method is faster? Is there anyway to see what LINQ does in the background?

Jon Skeet
people
quotationmark

Is there anyway to see what LINQ does in the background?

Well, you could look at my Edulinq implementation and the accompanying blog posts to get an idea of what's going on in LINQ to Objects. Obviously it's not the real implementation, but it will give you a good enough idea.

I would strongly suggest setting yourself some reasonable performance targets, implementing the code in the simplest possible way (which is almost certainly to use LINQ) and then seeing whether it meets your targets.

There are situations where hand-coding this sort of thing can bring significant improvements - but they're relatively rare, and you should only go for that after proving that it's worth it, IMO. LINQ is at least "pretty good" when used properly.

people

See more on this question at Stackoverflow