數據標準化假設我們有一些非規範化的數據,這樣的:與LINQ
List<string[]> dataSource = new List<string[]>();
string [] row1 = {"grandParentTitle1", "parentTitle1", "childTitle1"};
string [] row2 = {"grandParentTitle1", "parentTitle1", "childTitle2"};
string [] row3 = {"grandParentTitle1", "parentTitle2", "childTitle3"};
string [] row4 = {"grandParentTitle1", "parentTitle2", "childTitle4"};
dataSource.Add(row1);
我需要它正常化,例如獲得IEnumerable < Child>,並填充了Child.Parent和Child.Parent.GrandParent。
重要的方法或多或少都很清楚。與Linq相比,它會更短嗎?
在一個查詢中效果更好,這對於更多實體應該是可擴展的。
我想是這樣單獨創建的IEnumerable <祖父母>,然後IEnumerable的<家長>與分配等
請可在此功能的方式來實現的提示?
你試過Groupby()嗎? – 2010-02-27 21:20:04
問題是如何在沒有重複的情況下創建和鏈接實體。 選擇(新的父母{GrandParent =新的父母}) 或者我錯過了什麼? – rudnev 2010-02-27 21:34:23