Conditioning on List Sum

It gives an error when I say condition on issues.Sum. how can I do it?

private async Task<CapabilityUtilizationPagedResultDto> GetCount(IEnumerable<CapabilityUtilizationDto> issues){
     var vfgrandtotal = issues.Sum(i => i.VFApprovedFinalEffort && i.SpecialRates=="test");
     var vfmd = vfgrandtotal / 19;
     return new CapabilityUtilizationPagedResultDto

>Solution :

Enumerable.Sum does not accept filtering delegate, it has overloads accepting delegate to produce a number to sum over. Try something like (based on comment assuming you want to sum all VFApprovedFinalEffort where SpecialRates is equal to test):

 var vfgrandtotal = issues
    .Where(i => i.SpecialRates == "test")
    .Sum(i => i.VFApprovedFinalEffort /* or any other expression to sum over*/);

Leave a Reply