I have the following one-to-many relation between two objects.
Parent
--> IList<Child>
Now, I have a List of Parent objects and I want the First Child of each parent in the list.
What is the best way to do this using Linq?
parents.Where(p => p.Children.Any()).Select(p => p.Children.First());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With