How would I convert this to an ASYNC call?
publicclassFoo{publicintId{ get;set;}publicint?ParentId{ get;set;}// other props}You can get children of one item using:
List<Foo>GetChildren(List<Foo> foos,int id){return foos.Where(x => x.ParentId== id).Union(foos.Where(x => x.ParentId== id).SelectMany(y =>GetChildren(foos, y.Id))).ToList();}For ex.
List<Foo> foos =newList<Foo>();
foos.Add(newFoo{Id=1});
foos.Add(newFoo{Id=2,ParentId=1});
foos.Add(newFoo{Id=3,ParentId=2});
foos.Add(newFoo{Id=4});GetChild(foos,1).Dump();// will give you 2 and 3 (ids)