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

Dispose of Command shouldn't break associated DataReader #203

Closed
MaceWindu opened this issue Dec 22, 2020 · 1 comment
Closed

Dispose of Command shouldn't break associated DataReader #203

MaceWindu opened this issue Dec 22, 2020 · 1 comment

Comments

@MaceWindu
Copy link

Describe the bug
I'm testing different database providers (as part of linq2db/linq2db#2643 feature implementation) and observe 3 behaviors:

  • provider doesn't allow multiple open data readers for connection
  • provider allow multiple open data readers for connection using same command object (AdoNetCore.AseClient falls here)
  • provider allow multiple open data readers for connection using separate command object per data reader (includes also all providers from previous entry)

But for AdoNetCore.AseClient there is one inconsistency (not observed for other ADO.NET providers) - it doesn't allow command disposal if data reader is still active:

System.ObjectDisposedException: Cannot access a disposed object.
   at AdoNetCore.AseClient.AseCommand.get_Connection() in C:\gitprojects\AdoNetCore.AseClient_master\src\AdoNetCore.AseClient\AseCommand.cs:line 331
   at AdoNetCore.AseClient.AseDataReader.EnsureSchemaTable() in C:\gitprojects\AdoNetCore.AseClient_master\src\AdoNetCore.AseClient\AseDataReader.cs:line 534
   at AdoNetCore.AseClient.AseDataReader.GetSchemaTable() in C:\gitprojects\AdoNetCore.AseClient_master\src\AdoNetCore.AseClient\AseDataReader.cs:line 516
   at LinqToDB.DataProvider.DataProviderBase.IsDBNullAllowed(IDataReader reader, Int32 idx) in c:\GitHub\linq2db\Source\LinqToDB\DataProvider\DataProviderBase.cs:line 283

As you can see from stack trace, data reader tries to access command from internal call to GetSchemaTable API and fails due command being already disposed.

I think it makes sense to refactor it to not fail this scenario.

Environment

  • AdoNetCore.AseClient nuget package version : 0.18.0
@MaceWindu
Copy link
Author

Actually, this is fine. There are more providers with such behavior

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