How to improve performance or simplify .NET code with linq -
How to improve performance or simplify .NET code with linq -
apart database operation, how can simplify or improve code linq ?
example to search in string
string search = "search in list"; ienumerable<string> results = mylist.where(s => s == search);
i utilize linq statements in loops. simple illustration instead of:
for (int = 0; < array.length; i++) { if (array[i] > 10) { ... } }
i might this:
foreach(var value in array.where(item => item > 10)) { ... }
i find myself needing first occurrence of value in list:
var first = orders.firstordefault(order => order.items.count > 1);
performance linq .net-4.0
Comments
Post a Comment