1
I need to create a function in linq
return me the minimum and maximum values of a field in a list. I was able to perform an SQL query in this way, but I need this in the syntax in linq
.
SELECT
MIN(DATALANCAMENTO),
MAX(DATALANCAMENTO)
FROM CONTACORRENTECOMISSOES
WHERE SEQUENCIALOTELOJISTA = 14 //
I tried to accomplish this way, but the system does not allow to use the .Where
.
var dtMin = unit.ContaCorrenteComissoes.Min(c => c.DATALANCAMENTO).Where(c => c.SequenciaLoteLojista == nuLote
var dtMax = unit.ContaCorrenteComissoes.Max(c => c.DATALANCAMENTO).Where(c => c.SequenciaLoteLojista == nuLote)
Can help?
min does not return a list, so you cannot call Where later, in other words do Where first, call min last
– Lucas Miranda