Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Dapper QueryMultiple/Query/Execute methods thread safe?

I'm using Dapper QueryMultiple/Query/Execute methods in my .net 4.5 code (Parallel library), I would like to know if it is thread safe.

Thank you,

Monica

like image 307
Monica Avatar asked Jun 07 '13 21:06

Monica


1 Answers

All of the internal meta-programming parts of dapper should indeed be thread-safe, and it sees enough heavy load on sites like stackoverflow that I'm pretty confident this is fine.

However, if you perform multiple concurrent operations on the same connection instance - then that comes down to whether a single ADO.NET connection is thread-safe; and in most cases, no it is not, AFAIK. So: don't do that. Multiple connections with their own operations should be fine though.

like image 196
Marc Gravell Avatar answered Oct 12 '22 12:10

Marc Gravell