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

Find a way to reset a session after CancelAsync is called #546

Open
sebastienros opened this issue May 3, 2024 · 0 comments
Open

Find a way to reset a session after CancelAsync is called #546

sebastienros opened this issue May 3, 2024 · 0 comments

Comments

@sebastienros
Copy link
Owner

Another problem I discovered with this, is that if you ever abort the inner transaction with CancelAsync, you set a flag which is never cleared, not even by BeginTransactionAsync, the session object is simply unusable afterwards. Which essentially means you have to create a new session object for every transaction (and since I have to use DI, it means I have to create a new DI scope for every transaction). I suppose that's probably not an unreasonable thing to need to do, I just wish it was documented or something.

CancelAsync() is here to prevent a session from being committed. Even if changes append after the call. The idea is that multiple components could change entities, but if any component says that the session should not be saved (validation error for instance) then it should keep that state.

If people think CancelAsync() is not supposed to handle that state and instead something like ModelError/ErrorState should be used (ASP.NET MVC) then they can still use that instead of calling CancelAsync.

Alternately we could add a ResetAsync() which would reset the session, by rolling back any transation or changes, and also re-initializing the cancel flag such that the session can be used as new.

@ovekaaven

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