✅ Combining a List inside of a Select
I have an object:
And when i want to grab them all from the database, I want them combined by
creationDate
using LINQ.
For example:
creationDate:2023-12-15, labels:[{1},{2}]
and creationDate:2023-12-15, labels:[{3},{4}]
would combine to create
creationDate:2023-12-15, labels:[{1},{2},{3},{4}]
The order of the elements in labels
doesn't matter, I just want them combined.4 Replies
Something like that?
Lemme try that
I put that in, im just converting the
DateTime
to a DateOnly so that they'll actually match lol
made some changes, this is what I have now @ZZZZZZZZZZZZZZZZZZZZZZZZZ,
(ICollection<Label>)p.Select(l => l.labels)
seems to be an ICollection<ICollection<>> tho, why would that be?Because each success has a collection of labels, and each group will be a collection of those collections
That's why I went through label and not success
You can use
.SelectMany()
instead of .Select()
there
That'll flatten itohhh, i didnt notice that XD
ok, ty
it works!! thank you so much!