dotnet / EntityFramework.Docs

Documentation for Entity Framework Core and Entity Framework 6
https://docs.microsoft.com/ef/
Creative Commons Attribution 4.0 International
1.62k stars 1.96k forks source link

Add example of querying for enumerable of parents in related data section #1185

Open Allann opened 5 years ago

Allann commented 5 years ago

This issue tracker is for documentation

For product issues, use https://github.com/aspnet/EntityFramework/issues

Is there an example or guidance that extends on the https://docs.microsoft.com/en-us/ef/core/querying/related-data#querying-related-entities part? The querying of related entities should also be possible in a list, should it not?

e.g. select Blogs where Posts edited >1 week ago. This obviously assumes a last edit date on a post.

All examples I can find are only related to a single parent.

ajcvickers commented 5 years ago

@Allann Can you elaborate on what you mean by, "The querying of related entities should also be possible in a list?"

Allann commented 5 years ago

that was why I added the example; but in normal TSQL you would write it like:

Select Blog.* From Blog inner join Post on Blog.Id = Post.BlogId where Post.EditDate > 12/12/2018

That is a very simplistic example, but in essence a way to return parent entities using child values in the criteria. Or have I just not understood how to write LINQ queryies for EF Core?