Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
538 B
2
Indexable
Never
public async Task<IEnumerable<Vaciadototal>> GetLastPeriod(string clientId, int count)
{
    var query = from v in _context.Vaciadototals
                where v.Numcliente.Trim() == clientId
                group v by v.Numcliente into g
                select new
                {
                    ClientId = g.Key,
                    LastPeriods = g.OrderByDescending(k => k.Periodo).Take(count)
                };

    var results = await query.SelectMany(g => g.LastPeriods).ToListAsync();

    return results;
}