Repository navigation
Make .ToLookupAsync() extension really async - #520
Merged
Merged
Conversation
snaumenko-st
approved these changes
Sep 14, 2026
Comment on lines
+1759
to
+1761
| await (await query.ExecuteAsync(cancellationToken).ConfigureAwaitFalse()) | ||
| .AsAsyncEnumerable() | ||
| .ToLookupAsync(tuple => tuple.Item1, tuple => tuple.Item2, null, cancellationToken); |
There was a problem hiding this comment.
Why not just make it like this?
Suggested change
| await (await query.ExecuteAsync(cancellationToken).ConfigureAwaitFalse()) | |
| .AsAsyncEnumerable() | |
| .ToLookupAsync(tuple => tuple.Item1, tuple => tuple.Item2, null, cancellationToken); | |
| await query.AsAsyncEnumerable().ToLookupAsync(tuple => tuple.Item1, tuple => tuple.Item2, null, cancellationToken).ConfigureAwaitFalse(); |
Collaborator
Author
There was a problem hiding this comment.
query.AsAsyncEnumerable() implementation
looks very different from
query.ExecuteAsync(cancellationToken)
may be they are semantically similar, but that is not obvious
There was a problem hiding this comment.
Perhaps ExecuteAsync is not truly async and more like in-memory result. Maybe it doesn't fit the purpose?
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d423a24. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Also:
QueryableTestas it expectsNotSupportedExceptionNote
Low Risk
Behavior change is limited to async lookup and in-memory query results; sync enumeration is unchanged, with async iteration still driven by the underlying enumerator.
Overview
ToLookupAsynconIQueryablenow builds the lookup via async enumeration instead of calling synchronousToLookupon the materializedQueryResultafterExecuteAsync.To support that path,
QueryResult's in-memoryEnumerableReadernow implementsAsAsyncEnumerator(via a smallIEnumerator→IAsyncEnumeratoradapter) rather than throwingNotSupportedException.EnumerableReaderis also updated to use a primary constructor.Reviewed by Cursor Bugbot for commit 52c18b8. Bugbot is set up for automated code reviews on this repo. Configure here.