For a transaction rollback I use using (var dbTran = context.Database.BeginTransaction())
. Before the dbTran.Commit()
I have a LinQ query to get some data.. However, the LinQ query
fails. I guess its because of the BeginTransaction
method which is not allowing to query to the database. Is my assumption correct and is there a way around to get this done.
Asked
Active
Viewed 200 times
0

user17400391
- 11
- 2
-
This question might be helpful: https://stackoverflow.com/questions/55208184/begintransaction-with-isolationlevel-in-ef-core – Klaus Gütter Sep 30 '22 at 06:14
-
What does “The Linq query fails” mean? Does it return an empty list? Does it throw an exception? If yes, provide the exact error message you are getting. – ckuri Sep 30 '22 at 06:56
-
i tried as suggested by @Klaus and modified the code to using `(var dbTran = context.Database.BeginTransaction(IsolationLevel.Read.Uncommited))` still i get an exception as ` InnerException {"Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding."} System.Exception {System.Data.SqlClient.SqlException}` I am getting this exception on query for the newly made transaction which is yet uncommitted. Is there a way to read even the uncommitted transaction. – user17400391 Oct 03 '22 at 09:29
-
@ckuri To explain the above error, the application allows user to create associates. On creation of an associate there are 4 transactions happening, 2 for saving the details in 2 associate tables and other 2 for updating the Audit table for the 2 entries. Here I am using `BeginTransaction(IsolationLevel.Read.Uncommited))` for the transactions to rollback to cater unprecedented scenarios. After saving an entry in the associate table I am querying for the record in the associate table where it gives me the above exception even though I am using `Read.Uncommited` – user17400391 Oct 04 '22 at 07:29