LINQ Performance Pitfall – Deferred Execution

2008-05-27
1 min read

When using LINQ, queries may bloat up to dozens of lines. My personal style is to take these queries and break them apart to smaller units of logic. To each unit of logic, I append a call to ToArray. @yosit asked me why I did it and I answered I was avoiding a possible pitfall. Here’s what I meant….

You can read the copy of the original post, or if that goes down too, you can try the Wayback Machine’s copy of it.

Context: This post was automatically imported from my old blog, which was originally hosted on Microsoft’s ASP.NET Community Blogs. When they shut it down, I dumped all of my old posts to Wordpress. You can still check out the original blog on the Wayback Machine.