-
Notifications
You must be signed in to change notification settings - Fork 920
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
BeginTransaction is not async results in connection to be opened async #3051
Comments
2 tasks
You can try to force session to open async connection before calling await (session.GetSessionImplementation().ConnectionManager.GetConnectionAsync(cancelationToken)).ConfigureAwait(false); |
@bahusoid thanks for that tip, I've created the following extension method around it which I'll test later. static class SessionExt
{
public async static Task<ITransaction> BeginTransactionAsync(
this ISession session,
IsolationLevel isolationLevel = IsolationLevel.Unspecified,
CancellationToken cancellationToken = default
)
{
await session
.GetSessionImplementation()
.ConnectionManager
.GetConnectionAsync(cancellationToken)
.ConfigureAwait(false);
return session.BeginTransaction(isolationLevel);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BeginTransaction is not async results in connection to be opened async. I'm not entirely sure but I assume
BeginTransaction
will result in a transaction to be started if not already running thus a connection to be opened. I'm getting FirstChangeExceptions on my NpgSql setupIn npgsql/npgsql#1183 it is mentioned this is because the connection is opened via
.Open
instead of.OpenAsync
. I looked in the code andDriverConnectionProvider
supports async but it seems it isn't used. Further analys shows thatDriverBase
doesn't have an async BeginTransaction.I think an async BeginTransaction makes sense but maybe there is a workaround?
The text was updated successfully, but these errors were encountered: