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
{
VFGrandTotal=vfgrandtotal,
VFMd=vfmd,
};
}
CodePudding user response:
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*/);