-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to .ThenInclude() multiple sub-properties #4716
Comments
Here is what you are after...
BTW because these are reference (and not collection) properties, you can do this for short. ThenInclude only becomes mandatory when you want to include after a collection navigation property.
|
BTW #4490 "More flexible Include API - allow walking back up include tree" is also relevant to this code. |
Thanks @rowanmiller, makes sense to me. I was about to try the former approach, but the latter one is more compact so I'll switch to that. Feel free to close this issue if appropriate. |
Is there any restriction on how deep you can go with
The |
it would be great this substitute syntax instead of repeat one thing consecutively instead of
` |
After doing this how exactly would I get a where condition from either C1 or C2? seems not to work when I try it with my repository pattern and EF6. Any leads here?
|
I also get errors when I try to use this code in EF Core:
I keep seeing this method mentioned, yet have never gotten it to work. |
include theinclude both works fine... b ut only problem is intellisense not identifying or showing the methods just type and then proceed all works fine ... |
Thanks. It took me a long time to realize that what I was trying to do was perfectly valid but that it just wasn't showing in intellisense. I should have just typed it anyway. Example:
intellisense does not work on the last item here. A list will pop up but it won't have SecurityAction in the popup:
Once I ignored intellisense and typed it out anyway then it built and ran correctly. |
Any news whether "Include.ThenInclude.AlsoInclude" syntax or similar will be implemented for a more elegant solution to this problem? |
It could change to IncludeSibling() or SisterInclude()... |
I can't believe this is still relevant in 6th month of 2021. Just created a query that has 22 lines of code because I had to do |
@Uraharadono only 22 lines of code? I just wrote one with 45 lines of Include() and ThenInclude() chaining. Admittedly, each on a new line for readability. I thought that there surely must be a better way by now but alas! |
Why is this closed without any follow up? |
Suppose I have the following entities:
Now suppose I want to retrieve all
A
's and include theirB
's and both ofB
'sC
sub-properties.I can do
db.A.Include(a => a.B).ThenInclude(b => b.C1)
to include one ofB
'sC
sub-properties, but as far as I can tell, there's no way to include both ofB
'sC
sub-properties. If I tack on another.Include()
, I'm dealing withA
's. If I tack on anther.ThenInclude()
, I'm now dealing withC
's. There's no way to deal withB
's beyond the first call to.ThenInclude()
.I propose that the
IIncludableQueryable
interface should also expose an.AndInclude()
method, which can be tacked onto a call to.ThenInclude()
to continue accessing the associated property.The text was updated successfully, but these errors were encountered: