public async Task <IEnumerable <(DateTime biddingDate, Bid winningBid)> > GetBiddingWinners(int loanId) { var spec = new Specification <Loan>(x => x.Id == loanId); spec.IncludeStrings.Add("Bids.User.Account"); Loan loan = await _loanRepo.FindFirstAsync(spec); IEnumerable <(DateTime biddingDate, Bid winningBid)> winners = loan.Bids .GroupBy(bid => bid.CreatedDate.Date) .Select(group => (group.Key, MaxByBidAmount(group))); Bid MaxByBidAmount(IGrouping <DateTime, Bid> group) { return(group.Aggregate((item1, item2) => item1.Amount > item2.Amount ? item1 : item2)); } return(winners); }