• Hello and welcome to our new forums. We upgraded our forum sites to a more robust and modern system which we hope you will enjoy. Be sure to check out your profile by clicking the button on the top right and configure your preferences, signature, time zone, avatar, etc. as you wish. If you need help with using this new forum'ware try the help link on the bottom right.

    Click here to review your account now.

Question Select # records from each group in LINQ

HLeyes

Member
Joined
Feb 10, 2016
Messages
11
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

HLeyes

Member
Joined
Feb 10, 2016
Messages
11
Programming Experience
10+
JohnH - thank you for that! That's exactly what I needed. The capabilities of LINQ amaze me every day.

HLeyes
 
Top Bottom