-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add async infrastructure for lazy-loading #10904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/EFCore/Internal/LazyLoader.cs
Outdated
|
||
return ShouldLoad(entity, navigationName, out var entry) | ||
? entry.LoadAsync(cancellationToken) | ||
: Task.FromResult(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Task.CompletedTask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this something we should now do everywhere? (Currently we use .FromResult(0) throughout the stack, based on recommendation from @AndriySvyryd)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it may not have been around previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any is fine for now, it'll be cleaned up by #7445
{ | ||
private readonly ICollection<LazyAsyncPsPost> _lazyAsyncPsPosts = new List<LazyAsyncPsPost>(); | ||
|
||
private Func<object, CancellationToken, string, Task> LazyLoader { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flip CancellationToken and name parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should discuss in API review--name is CallerMemberName which should also be last, and the signature of this func must currently match the signature of the method (since there is no manipulation of the order, etc. when building the expression tree.)
4ea4c00
to
76cb459
Compare
76cb459
to
7a0ad41
Compare
Thanks for doing that, it is a great API addition! |
Part of #10509, #3797
Adds ILazyLoader.LoadAsync and allows binding to delegate for it.