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

Ability to provide an existing DbTransaction to the session builder #3400

Open
danielmarbach opened this issue Aug 7, 2023 · 0 comments
Open

Comments

@danielmarbach
Copy link

Currently it is already possible to provide an existing connection to the session builder with the following approach

var sessionBuilder = sessionFactory.WithOptions();
sessionBuilder.Connection(existingDbConnection);
var session = sessionBuilder.OpenSession();

this is great to be able to pass externally managed connections into a new session. In NServiceBus we have a SqlServer transport that manages under certain transport transaction modes connections and transactions for every incoming message. For those scenarios it would be great if we could customize the session with an already existing transaction too by doing for example

var sessionBuilder = sessionFactory.WithOptions();
sessionBuilder.Connection(existingDbConnection, existingDbTransaction);
var session = sessionBuilder.OpenSession();

as of now it seems this would only be possible by doing complicated decoration of session factory and transaction factory to achieve the same.

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

No branches or pull requests

1 participant