Using LINQ to query MULTI LEVEL object hierarchy [modified]
-
Hi, I have an MULTI LEVEL hierarchical collection object - List<MyApplication> apps = new List<MyApplication>(); The MyApplication object contains following properties - int ApplicationId, List<MyApplication> MyApplications, string AppName and so on.. When my application starts, the apps "multi level" collection object gets filled up. Now on a particular action on an page, I need to get/search for an Application object that has ApplicationId = 308 (in real time this number would come dynamically). This is easily possible by looping through the collection object and comparing the ApplicationId property with variable holding value 308. But I wanted to know if this is possible using LINQ query to get an "MyApplication" object with ApplicationId as 308? I tried searching on this issue but came across examples with fixed hierarchy level. Your suggestion/pointers to this issue would be highly appreciated Note: 1. The level of the object hierarchy is not fixed and can vary. 2. ApplicationId would be UNIQUE for all MyApplication object(s) in the hierarchy.
Regards, Vipul Mehta
modified on Sunday, November 1, 2009 10:49 PM