c# - Combining LINQ statements for efficiency -


Regarding linq for objects, if I use one. Where (x => x ....) and then use it directly later. A .pipoil (x => x ...) Does it impose a performance penalty because I am going to the collection twice?

Should I put everything where or in the Closing Clause?

Use one where and leave while the result is "not going to the collection twice." The LINQ object works on a pull model. When you calculate the combined query, SkipWhile will start asking for your source for elements. Where is its source, hence the reason for starting its source instead of the elements. So SkipWhile will see all the elements that pass the clause, but it is getting them as it goes. The result of this is that LINQ does an advanced task on the original collection, only returns to those elements where and to leave, while the two filter - and there is only one pass on the archive in it.

There may be a trivial loss due to efficiency, it involves two doublings, but it is unlikely to be important, you should write to clarify the code (as you are doing at this time) , And if you suspect that the apparent version performance is causing the problem, try to combine the solution to make sure , and then only


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -