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
VulpesPosted Nov 25, 2014, 7:46 AM
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 BangerPosted Nov 25, 2014, 1:03 AM
if you want Exact Time Measurement of between process you try this method.
after this function you can compare which is give best performance .
Tamas SPosted Nov 24, 2014, 2:26 PM
Joginder BangerPosted Nov 24, 2014, 2:23 PM
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