Wednesday, January 15, 2014

How to improve the performance of Linq IEnumerable to Object List

I found an issue with the my linq code. it is straight forward code. it simply call a Ienumerable object to list

List<myObject>=myIenumerable.ToList<myObject>();

as the number of objects in the Ienumerable Increases. the app take noticeable time to load the data. 
 
 the good search return the following will provide a great help to solve the issue.

http://msmvps.com/blogs/jon_skeet/archive/2011/01/01/reimplementing-linq-to-objects-part-20-tolist.aspx 

I changed my code to 

List<myObject>=new List<myObject>(myIenumerable);

the performance take a big jump.