There is not a single answer that will be enough.
LINQ has many uses and many implementations, and therefore many implications for the effectiveness of your code.
As with every technology at your fingertips, LINQ can and will abuse and abuse the same way, and the ability to distinguish between this and the right use depends on only one thing: knowledge.
Therefore, the best advice I can give you is to familiarize yourself with how LINQ is really implemented.
Things you should check out:
- LINQ and methods for using extension methods and methods for existing collection types
- How LINQ Works
- How LINQ works inside (stack overflow)
- How does encoding with LINQ work? What is going on behind the scenes?
- How LINQ-to-objects and LINQ-to-SQL differ
- What is the difference between LINQ query expressions and extension methods (stack overflow)
- Alternatives to the new LINQ syntax, such as using the .Where (...) extension method for collections
And as always, when considering performance issues, the only safe approach is to simply measure. Create a code snippet using LINQ, which does one thing, knows something, and creates an alternative, then measures both. Guessing and assuming will only lead to poor results.
Lasse Vågsæther Karlsen Jul 25 '09 at 20:17 2009-07-25 20:17
source share