Are Dapper QueryMultiple/Query/Execute methods thread safe?

.net dapper multithreading sql-server thread-safety

Question

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

Accepted Answer

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.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why