Skip to content

Make .ToLookupAsync() extension really async - #520

Merged
SergeiPavlov merged 3 commits into
master-servicetitanfrom
ToLookupAsymc
Oct 1, 2026
Merged

SergeiPavlov merged 3 commits into
master-servicetitanfrom
ToLookupAsymc

Conversation

@SergeiPavlov

@SergeiPavlov SergeiPavlov commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Also:

  • Mute QueryableTest as it expects NotSupportedException

Note

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
ToLookupAsync on IQueryable now builds the lookup via async enumeration instead of calling synchronous ToLookup on the materialized QueryResult after ExecuteAsync.

To support that path, QueryResult's in-memory EnumerableReader now implements AsAsyncEnumerator (via a small IEnumerator → IAsyncEnumerator adapter) rather than throwing NotSupportedException. EnumerableReader is 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.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment on lines +1759 to +1761
await (await query.ExecuteAsync(cancellationToken).ConfigureAwaitFalse())
.AsAsyncEnumerable()
.ToLookupAsync(tuple => tuple.Item1, tuple => tuple.Item2, null, cancellationToken);

@snaumenko-st snaumenko-st Sep 14, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query.AsAsyncEnumerable() implementation
looks very different from
query.ExecuteAsync(cancellationToken)

may be they are semantically similar, but that is not obvious

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps ExecuteAsync is not truly async and more like in-memory result. Maybe it doesn't fit the purpose?

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

@SergeiPavlov
SergeiPavlov merged commit 65d0cdf into master-servicetitan Oct 1, 2026
89 checks passed
@SergeiPavlov
SergeiPavlov deleted the ToLookupAsymc branch October 1, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants