C# Linq Grouping and Distinct

var px = parents.SelectMany(p => p.Childs.Select(c => new {
                        number = c.Number,
                        parent = p
                 })).GroupBy(g => g.number).Distinct().Select(s => s.First())
                .GroupBy(g => g.parent)
                .Select(s => s.First());
It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *