獲得不同的ID列表我有一個類中的屬性,我需要通過從一個關係的所有可能的不同的ID進行迭代。LinqToSql - 從一個嵌套列表
我是一個用戶,這屬於公司內部。公司有許多解決方案,每個解決方案都有許多「解決方案門戶」。我想要的是來自數據庫中「SolutionPortals」(SolutionPortal.PortalID)的所有不同「PortalIds」的列表。
我不能爲我的生命得到這個作爲一個單獨的列表。我不斷收到:
var solutionIds = from s in this.Company.Solutions.Select(s=>s.SolutionPortals)
select s.Select(sp=> sp.PortalID);
當然,這是有道理的,因爲有解決方案的列表,與SolutionPortals的名單,但我只是需要選擇IDS到各自的名單。
IEnumerable<IEnumerable<int>> // <-- Don't want this
IEnumerable<int> // <-- I want this
任何幫助將極其讚賞。
感謝/
這讓我走上了正確的道路。謝謝!我不知道「SelectMany」擴展名。非常便利。 – 2009-07-07 21:06:13