-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Read after SaveChanges does not work inside transaction #22
Comments
+1 |
Hello, I have the same problem. Normal EF working with this situation... Can someone repair it please? 🔢 Thank you |
Since this issue has been known about for a few years and is probably difficult to fix without significant changes to Effort, I wouldn't hold my breath waiting for a fix. As a workaround I've added a flag to my context class, and when the flag is set to true I simply don't use transactions. As long as you're not running multiple operations against the same context at the same time the transactions shouldn't be too important to the tests. This gist shows one way to "disable" transactions for tests: https://gist.github.com/magnusbakken/671abb7cf43798cffdb45f29bb839fe1 Use |
Hello,
Thank you 😊 I will try it 😊
From: Magnus Grindal Bakken [mailto:[email protected]]
Sent: Monday, January 8, 2018 2:34 PM
To: zzzprojects/effort <[email protected]>
Cc: Mediel <[email protected]>; Comment <[email protected]>
Subject: Re: [zzzprojects/effort] Read after SaveChanges does not work inside transaction (#22)
Since this issue has been known about for a few years and is probably difficult to fix without significant changes to Effort, I wouldn't hold my breath waiting for a fix. As a workaround I've added a flag to my context class, and when the flag is set to true I simply don't use transactions. As long as you're not running multiple operations against the same context at the same time the transactions shouldn't be too important to the tests.
This gist shows one way to "disable" transactions for tests: https://gist.github.com/magnusbakken/671abb7cf43798cffdb45f29bb839fe1
Use using (var transaction = Context.BeginTransaction()) { ... } to start transactions in your production code, and set IsInMemoryTestContext = true when you create contexts in your test code. I test for the same property for some other stuff that Effort doesn't support, such as ExecuteSqlCommand.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#22 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/APlBk-6a1unYhmaece3jXxGSvTwNmCmJks5tIhk5gaJpZM4GAS01> .
|
I love using Effort/NMemory for my testing, but now I ran into a problem:
When I use an explicit transaction (since I want to be able to do a rollback), the results of SaveChanges are not visible until I do a commit:
This behavior is different from SQL Server, which makes newly stored rows visible inside the transaction (so the value of total would be 1). My code relies on this to check what has already been stored.
Is there anything I am doing wrong or is this a bug?
The text was updated successfully, but these errors were encountered: