what is the best LINQ approach for with no performance loss? how could we do the same thing using LINQ iterating the list only once?
class Employee
{
Try this for getting the total income
var totalIncomeOfToList = myList.Where(e => e.empType == 1).Sum(e => e.income);
If you also want the list of filtered employees then:
var toList = myList.Where(e => e.empType == 1).ToList();
var totalIncomeOfToList = toList.Sum(e => e.income);
The performance will be slightly better with a foreach, but this way the code will be much clear and precise.