Entity Framework 6: Pull in Child Entities with Async WebAPI 2.0

    Just a quick piece of code to get all the children under a given parent. The solutions is pretty straight forward but took sometime to think about since I wanted to keep the result asynchronous. I was also thinking of how I would use scaffolds creates other apis with my models.


db.Product.Include(x=>x.ProductChildren).SingleOrDefaultAsync(x => x.Id == id);

    Its late at nite (so no judging...) but I wanted to get my thoughts down and explore this code for a bit. The piece code is async but my question is does it pull the child entities after it has filter down on the parent id? Or does it pulls in all the children before it has filtered down on a particular partent id and if not wouldn't a more proper way to do it be more something like...


This code doesn't work of course, since the Include doesn't exist for 'FindAsync' but either way alternative I believe might be with the 'ContinueWith()' method which I haven't had a chance to look at.

Eagerly loading multiple levels
Navigation Properties

Popular posts from this blog

Installing Windows on Acer chromebook 15 cb3-532

Entity Framework: ToListAynsc & WhereAsync

CSharp Cheatsheet