I'm trying to implement SUM
within these lines of code to sum the two columns Litro
and TotalGasto
Code:
var teste = consulta.Where(i => i.DtAbastecido >= dataInicio &&
i.DtAbastecido <= dataFinal)
.Sum(x =>x.Litro)
.GroupBy(x => new { x.NumCarro.NCarro })
.Select(x => x.First())
.OrderBy(x => x.NumCarro.NCarro);
But I'm getting the following error:
'int' does not contain a definition for 'GroupBy' and no extension method 'GroupBy' accepting a first argument of type 'int' could be found (are you missing a reference or an assembly reference?)