c# - Awkward behaviour with TAKE in EF Core query - Stack Overflow

If I explain a bit on my entities there is Routing entity. Then it has Steps in an one-to-many relation

If I explain a bit on my entities there is Routing entity. Then it has Steps in an one-to-many relationship.

public class Routing 
{
    public Guid Id { get; set; }
    public Guid? DriverId { get; set; }    
    public List<Step> Steps { get; set; }
}

public class Step 
{   
    public Guid Id { get; set; }   
    public Routing Routing { get; set; }
    public Guid? RoutingId { get; set; }
    public Guid? MenTaskId { get; set; }
    public MenTask MenTask { get; set; }
}

Here is my EF Core query that I'm executing for getting routing and all linked step data:

List<Routing> routes = await _Routing.GetQueryableAsync())
                                     .Include(x => x.Steps)
                                     .OrderBy(Sorting)
                                     .Skip(SkipCount)
                                     .Take(MaxResultCount)
                                     .ToList();

My question is, if I provide a MaxResultCount of 10, then it will not retrieve data for Steps array. But If I provide like 30 or above, then it will display steps data.

Then I try to google the issue and some says add below, and it didn't work.

foreach (var routing in routes)
{
    await _Routing.EnsureCollectionLoadedAsync(routing, x => x.Steps);
}

Some says to add .AsSplitQuery() before Skip() and Take, but that also won't work.

Any expert can guide me to trace the issue with above simple query?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745287879a4620672.html

相关推荐

  • c# - Awkward behaviour with TAKE in EF Core query - Stack Overflow

    If I explain a bit on my entities there is Routing entity. Then it has Steps in an one-to-many relation

    21小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信