Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

How to convert the below to Async Call

$
0
0

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)

Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>