Skip to main content
1 of 2
Bobson
  • 1k
  • 5
  • 13

You should use MaxBy() from here, which is taken from MoreLINQ.

var items = rep.FindWhere(i => i.ID == itemID)
               .Select(i => i.Batch)
               .SelectMany(b => b.Items);

var NextItem = items.Where(i => i.StatusID == (short) ItemStatus.Pending)
                    .MaxBy(i => i.NumInBatch);

return NextItem.ID;
  
Bobson
  • 1k
  • 5
  • 13