How do I query a parent's relationship with a parent:
- Filter < / Li>
- Both parents and children
- Return a list or parent with previously-populated children
If I try Include _context.parents.Include ("children") from png
png in c in the _context.childrenon p.Id equals c.ParentId where d.DeletedDate == by empty command p. Name ascending, c.Name
P>
The result I want to return is a
IEnumerable & lt; Parent & gt; or
Parents [0] .name = "foo" parent [0]. Children = IEnumerable & lt; Child & gt; Parents [1] .name = "bar" guardian [1]. Children = INMERABLE & lt; Child & gt;
This solution depends on what you want to do.
The first question gives the impression that you want to "level up" the results of objects, such as (pseudocode, I hope it is clear what I mean): < In this case, each result in the "row" is a
parent < / Code> and an
child property, and you can sort by the name of the parent and after the child's name.
Only the
parent object returns in the second query and (you do not want to show it but I think the EF has given instructions to do this) is the collection in this case you can sort only according to the parents name; If you want to sort the children of each
parents , then sort the
children collection on that object.
Which of the two of you?
Update
OK, it seems that you want another I do not believe it can be done directly when you can do it You show results - Since
parents have already been sorted, just sort the children of each:
var sorted children = mother- husband. children. Order (c => c.Name);
Comments
Post a Comment