How to limit number of related data with Include
It is not possible with eager loading (Include
) - eager loading returns always all related data. You must use projections to anonymous or new type (you cannot use your existing mapped entities):
var cats = context.Cat.Select(c => new
{
Category = c,
Posts = c.Posts.OrderBy(p => p.Name).Take(10)
});