dotnet / EntityFramework.Docs

Documentation for Entity Framework Core and Entity Framework 6
https://docs.microsoft.com/ef/
Creative Commons Attribution 4.0 International
1.56k stars 1.94k forks source link

Wrong type on LazyLoader #4683

Closed belav closed 2 months ago

belav commented 2 months ago

Type of issue

Typo

Description

The article uses Action<object, string> for the type of lazyLoader, but there is an interface ILazyLoader which should be used.

Page URL

https://learn.microsoft.com/en-us/ef/core/querying/related-data/lazy

Content source URL

https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/querying/related-data/lazy.md

Document Version Independent Id

7c665098-afcc-1ba0-d6a2-0262ae921575

Article author

@roji

ajcvickers commented 2 months ago

@belav Can you be more specific? I see ILazyLoader being used in the examples that show its use, and Action<object, string> in the examples that show its use. Everything seems correct.

belav commented 2 months ago

@ajcvickers ah, I didn't realize it was showing two different ways to do things on that page, was just scanning it quick. I ended up copying the example for the delegate which still tries to call the method as it were using ILazyLoader. I added a comment below to the code



    private Blog(Action<object, string> lazyLoader)
    {
        LazyLoader = lazyLoader;
    }

    private Action<object, string> LazyLoader { get; set; }

    public int Id { get; set; }
    public string Name { get; set; }

    public ICollection<Post> Posts
    {
        // this isn't valid, maybe it should be LazyLoader.Invoke(this, "_posts")
        get => LazyLoader.Load(this, ref _posts);
        set => _posts = value;
    }