Question Select # records from each group in LINQ

HLeyes

Member
Joined
Feb 10, 2016
Messages
15
Programming Experience
10+
I have a list of customers and invoices. The number of invoices per customer could be one or many. I am looking for a LINQ statement that would produce a list that would have only a specific number of records for each customer - let's say three per customer, whether the customer has one or a hundred. The original list will be sorted by customer number, then by invoice date descending. The goal is to produce a list of each customer with a maximum of three invoices (the most recent). Please see the attached screenshot.

Any help would be appreciated! Thanks.

HLeyes
 

Attachments

  • j_Multiple Records per Customer - Capture.PNG
    j_Multiple Records per Customer - Capture.PNG
    6.5 KB · Views: 152
Last edited:
Back
Top Bottom