hierarchical-grouping

How do I write a LINQ query that inverts the grouping of a hierarchical data source?

☆樱花仙子☆ 提交于 2019-12-21 02:41:36
问题 How would one write a LINQ query which takes a hierarchical source data and transforms it so that the grouping is inverted? Say I have a list of Topic objects each of which contains a collection of Tags which represent meta-data tags on that topic. What I need is to write a LINQ query to basically flip the hierarchy inside out so that I have a list of Tags each of which have a collection of topics that are tagged with that particular tag. Topic { Title = "Political Debate #1", Posted = 01/02