Hello,
Could You please advise me a book or any reference where I can find information about the Linq method comparision based on its effectiveness ?
I am interested in becasue I want to use a correct method in any situation like use Any(), instead of Count() > 0, and I would like to find any implementation details, why one is better than others
Thanks in advance

VulpesRank #55 · 29.2K reputationPosted Nov 25, 2014, 2:46 AM EST
http://www.amazon.com/5-0-Nutshell-The-Definitive-Reference/dp/1449320104
For example, I learned from this book that the Count() method checks internally whether the input sequence implements ICollection
Consequently, in those situations, Count() > 0 should be faster than Any() which needs to start iterating through the collection to see if there's at least one element in the sequence.
However, if the input sequence doesn't implement ICollection
Note that the above remarks apply to LINQ to objects. In the case of LINQ to SQL and Entity Framework, I wouldn't necessarily assume that the position will be the same as it will depend on the relative effectiveness of the equivalent functions within the database itself.
Joginder BangerRank #360 · 7K reputationPosted Nov 24, 2014, 8:03 PM EST
if you want Exact Time Measurement of between process you try this method.
It's a namespace must be use for Stopwatch class:- using System.Diagnostics; Stopwatch sw = new Stopwatch(); sw.Start(); //....do stuff here --like your loops and another function. sw.Stop(); Console.WriteLine("Elapsed={0}",sw.Elapsed);after this function you can compare which is give best performance .
Joginder BangerRank #360 · 7K reputationPosted Nov 24, 2014, 9:23 AM EST
Here is one link you can download this book. it's free of cost.
http://www.c-sharpcorner.com/ebooks/free/78/linq-quick-reference-with-C-Sharp.aspx
Tamas S7 reputationPosted Nov 24, 2014, 9:26 AM EST