Open Closed

Does IRepository support Explicit Loading with EF Core? #3304


0
trendline created

Explicit Loading support was introduced in EF Core 1.1.0. With below API

using (var context = new BloggingContext()) 
{
    var blog = context.Blogs
        .Single(b => b.BlogId == 1);

    context.Entry(blog)
        .Collection(b => b.Posts)
        .Load();

    context.Entry(blog)
        .Reference(b => b.Owner)
        .Load();
}

As it is using DbContext, is there a way that could use them in IRepository?


7 Answer(s)
  • 0
    ismcagdas created

    Hi,

    You can use EnsureLoadedAsync for this. An example would be:

    var person = await _personRepository.GetAsync(Id);
    await _personRepository.EnsureLoadedAsync(person, p => p.Phones);
    

    Or you can use GetAllIncluding on IRepository.

    Thanks.

  • 0
    trendline created

    Thanks, @ismcagdas, I found this extension, It seems the "reference" API not in this extension, would you extend it in the future?

    Does GetAllIncluding method implemented via eager loading?

  • 0
    ismcagdas created

    Hi @trendline,

    It seems the "reference" API not in this extension, would you extend it in the future?

    We will add it for the next coming release.

    Does GetAllIncluding method implemented via eager loading?

    Yes, because EF Core does not support lazy loading at the moment.

    Thanks.

  • 0
    trendline created

    Got it. thanks, look forward to lazy loading released with EF Core 2.0.

  • 0
    ismcagdas created

    Hi,

    We hole as well :). Your first requirement is implemented here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2181">https://github.com/aspnetboilerplate/as ... ssues/2181</a>. Will be in the next release of ABP.

    Thanks.

  • 0
    trendline created

    Great to see it already be implemented, as V2.1 with lots of changes, when it will be released?

  • 0
    ismcagdas created

    Hi,

    Probably this week.