Nevermore icon indicating copy to clipboard operation
Nevermore copied to clipboard

System.InvalidOperationException when disposing a read transaction

Open RolandKoenig opened this issue 2 years ago • 1 comments

I'm testing a few cases with Nevermore and encountered an exeception when disposes a ReadTransaction: System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first.

You can see the code here: The exeception is thrown on the end of the program (when dispose is called because of the using statement in line 74) https://github.com/RolandKoenig/HappyCoding/blob/main/2022/HappyCoding.JsonDocumentsWithNevermore/HappyCoding.JsonDocumentsWithNevermore/Program.cs I'm using the version 17.0.1 of Nevermore

Is there anything wrong with my code or is this a bug?

RolandKoenig avatar Mar 13 '22 10:03 RolandKoenig

This call needs an 'await', otherwise you are telling the GC to keep alive the task that will eventually load the document, not the document itself:

            var readDocument =
                readTransaction.LoadRequiredAsync<TestingDocument>(expectedDocument.ID);

PaulStovell avatar Nov 23 '22 06:11 PaulStovell