私は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 を使用して 2 番目のリストをマージしたいと考えています。
たとえば、Original リストには Orange のエントリが 1 つしかなく、Normal リストの 2 つのエントリを Original リストに追加したいと考えています。バナナも同様です。
どうすればLINQでそれを達成できますか?
あなたの助けと時間をありがとう
------------RESULT 実現したいこと
//FinalResult
//Apple
//Red Apple
//Green Apple
//Orange
//Blood Orange
//Sweet Orange
//Peach
//Green Grapes
//Black Grapes
//Bananas
//Yellow Banans
//Green Bananas