Skip to content
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

Support for BeginTransactionAsync #3052

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ramonsmits
Copy link
Contributor

@ramonsmits ramonsmits commented Apr 27, 2022

Resolves: #3051

Todo:

  • Cancellation tokens arguments
  • Missing some #if to as BeginTransactionAsync only exists since NET Standard 2.1

Comment on lines +116 to +131

#if NETSTANDARD2_1_OR_GREATER
public async Task<ITransaction> BeginTransactionAsync(IsolationLevel isolationLevel)
{
EnsureTransactionIsCreated();
await _transaction.BeginAsync(isolationLevel).ConfigureAwait(false);
return _transaction;
}

public async Task<ITransaction> BeginTransactionAsync()
{
EnsureTransactionIsCreated();
await _transaction.BeginAsync().ConfigureAwait(false);
return _transaction;
}
#endif
Copy link
Member

Choose a reason for hiding this comment

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

No manual editing of generated code files (see their header) can be allowed.

Almost all the "coding" for async happens in the AsyncGenerator yaml file. To diagnose why it does not generate a BeginTransactionAsync by itself, run the aync generator (see contributing.md) and analyze its output.

Either we have disabled it for this member on purpose (then look in git history from where it comes to find the rational) or it may not actually trigger a connection opening as you seem to assume. (I have not checked anything.) Maybe some other cause is in play, like an async candidate access triggered by a property access, case which cannot be converted to async. Such cases will de diagnosed in the async generator output.

Copy link
Member

Choose a reason for hiding this comment

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

why it does not generate a BeginTransactionAsync by itself

Two reasons:

  1. The target generation is set to netstandard2.0
  2. The return type is ValueTask<> that is yet not supported by AsyncGenerator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't notice these files were autogenerated :-(

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.

BeginTransaction is not async results in connection to be opened async
3 participants