I have the following query:
public IEnumerable<Team> GetAllTeamsWithMembers(int ownerUserId)
{
return _ctx.Teams
.Include(x => x.TeamMembers)
.Where(x => x.UserId == ownerUserId)
.OrderBy(x => x.Name).ToList();
}
How do I go about ordering the teams by their name, and then have all the child members of each team sorted by their name?
It seems that do this I need to create a new DTO class and use a select. I'd like to use the EF entities already created, in this case Team has a navigation property to Members. I return IEnumerable<Team>
out from my repository layer.
There doesn't seem to be a neat way of ordering child collections in EF. Can anyone help?