我有 2 个列表:-
OrigFruitList.Add(new Fruit { Category = "Apple", SubCategory = "" });
OrigFruitList.Add(new Fruit { Category = "Apple", SubCategory = "Red Apple" });
OrigFruitList.Add(new Fruit { Category = "Apple", SubCategory = "Green Apple" });
OrigFruitList.Add(new Fruit { Category = "Orange", SubCategory = "" });
OrigFruitList.Add(new Fruit { Category = "Peach", SubCategory = "" });
OrigFruitList.Add(new Fruit { Category = "Grapes", SubCategory = "Green Grapes" });
OrigFruitList.Add(new Fruit { Category = "Grapes", SubCategory = "Black Grapes" });
OrigFruitList.Add(new Fruit { Category = "Bananas", SubCategory = "" });
NormalFruitList.Add(new Fruit { Category = "Apple", SubCategory = "" });
NormalFruitList.Add(new Fruit { Category = "Apple", SubCategory = "Red Apple" });
NormalFruitList.Add(new Fruit { Category = "Apple", SubCategory = "Green Apple" });
NormalFruitList.Add(new Fruit { Category = "Orange", SubCategory = "Blood Orange" });
NormalFruitList.Add(new Fruit { Category = "Orange", SubCategory = "Sweet Orange" });
NormalFruitList.Add(new Fruit { Category = "Peach", SubCategory = "" });
NormalFruitList.Add(new Fruit { Category = "Bananas", SubCategory = "" });
NormalFruitList.Add(new Fruit { Category = "Bananas", SubCategory = "Yellow Bananas" });
NormalFruitList.Add(new Fruit { Category = "Bananas", SubCategory = "Green Bananas" });
现在我希望根据第一个列表合并第二个列表,如果可能的话与 LINQ 合并。
例如,原始列表中只有 1 个橙色条目,我希望将正常列表中的 2 个条目附加到原始列表中。香蕉也是如此。
如何使用 LINQ 实现这一目标?
感谢您的帮助和时间
------------RESULT 我希望实现
//FinalResult
//Apple
//Red Apple
//Green Apple
//Orange
//Blood Orange
//Sweet Orange
//Peach
//Green Grapes
//Black Grapes
//Bananas
//Yellow Banans
//Green Bananas