Is SqlConnection / SqlCommand thread safe?

前端 未结 3 1017
暗喜
暗喜 2020-12-18 07:28

I am currently creating a WCF web service.

As part of its job, it will unfortunately need to do some fairly intensive computations, however these computations can fo

3条回答
  •  眼角桃花
    2020-12-18 08:20

    just use connection and command from knly one thread and dont care of app level thread issue on those. sql server is good enough to handle concurrency for you with no need to lock in your code. .Net connection pool is also there to retrieve valid connections fast.

    I am not saying the whole WCF layer you make should not care of threads, but its DAL has to work relying on db locks not .net locks.

提交回复
热议问题