Skip to main content
Stack Overflow is like an encyclopedia, so we prefer to omit these types of phrases. It is assumed that everyone here is trying to be helpful.
Source Link
Dharman
  • 33.9k
  • 27
  • 106
  • 157

In addition to needing to order, I needed to limit the results of the children. I did it like this:

var transactions = await _context.Transaction .Include(x => x.User) .OrderByDescending(x => x.CreatedAt) .Where(x => x.User.Id == _tenantInfo.UserId) .Take(10) .ToListAsync(); var viewmodel = _mapper.Map<UserViewModel>(transactions.First().User); 

Hope this helps!

In addition to needing to order, I needed to limit the results of the children. I did it like this:

var transactions = await _context.Transaction .Include(x => x.User) .OrderByDescending(x => x.CreatedAt) .Where(x => x.User.Id == _tenantInfo.UserId) .Take(10) .ToListAsync(); var viewmodel = _mapper.Map<UserViewModel>(transactions.First().User); 

Hope this helps!

In addition to needing to order, I needed to limit the results of the children. I did it like this:

var transactions = await _context.Transaction .Include(x => x.User) .OrderByDescending(x => x.CreatedAt) .Where(x => x.User.Id == _tenantInfo.UserId) .Take(10) .ToListAsync(); var viewmodel = _mapper.Map<UserViewModel>(transactions.First().User); 
Source Link

In addition to needing to order, I needed to limit the results of the children. I did it like this:

var transactions = await _context.Transaction .Include(x => x.User) .OrderByDescending(x => x.CreatedAt) .Where(x => x.User.Id == _tenantInfo.UserId) .Take(10) .ToListAsync(); var viewmodel = _mapper.Map<UserViewModel>(transactions.First().User); 

Hope this helps!