ElNinjaGaiden / Dapper.DataRepositories

Base structures to implement Data Repository pattern upon Dapper as MicroOrm.
90 stars 31 forks source link

Reusing Connection Causes Errors #5

Open Mx-Boyan opened 9 years ago

Mx-Boyan commented 9 years ago

When re-using the same SQL connection for more than one data reader for the same command, the query fails with DataReader already open.

Yoinbol commented 9 years ago

I think that's something handled by the base Dapper library instead of my extension.

Mx-Boyan commented 9 years ago

I don't think it is handled by Dapper internally, just look at all the examples of using Dapper. It doesn't care about opening or closing the connections, you are responsible for setting that up. The issue with your repository implementation is that you setup the connection once (inside the constructor) and re-use it for every call, instead of setting it up before you call dapper and then disposing it. I can create a fork and a submit a PR if you want to see what I mean.