Let's say I have an IQueryable that will return a data type with an ID property (column).
I want to continue filtering my request (I do not want to evaluate the request) as follows:
For each unique ID from the main request, I want Take(n) , where n is some arbitrary number.
That is, I want to save only the first lines of n for each unique identifier.
I can get a great ID s ...
var ids = query.Select(q => q.ID).Distinct();
and I can Take(n) with the rest of them, but I canβt say that I connect two:
query = query.<FOR EACH DISTINCT ID>.Take(n);
The accepted answer works, but slow for a large table. I wrote this question as a follow-up.
source share