Sounds like a bug, and pretty sure it is already listed. I have a new year's resolution to clear the backlog so I should get to that soon.
Why does Dapper Open for Query but not Execute
-
01-10-2022 - |
Domanda
I realize this might simply be a bug or oversight, but I sincerely doubt it:
When I run the following code:
using(var cnn = new SqlConnection(cnnString)) {
return cnn.Query<Foo>("select top 15 * from Foo");
}
The Dapper Query method opens the connection before it runs anything.
When i run this code:
using(var cnn = new SqlConnection(cnnString)) {
cnn.Execute("insert Foo(bar_id, name) values (@bar_id, @name)", fooList);
}
The code throws with an InvalidOperationException:
ExecuteNonQuery requires an open and available Connection.
The connection's current state is closed.
It sounds like this question, but I can't tell if there's some reason why Execute can't be doing the same logic.
My question is why, or if not, should I file a bug?
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow