How use “using” in my Connection Class

前端 未结 1 1186
清酒与你
清酒与你 2021-01-25 15:34

I want to use using for SqlConnection in my code like this

using (SqlConnection Con = new SqlConnection())

But I have used d

相关标签:
1条回答
  • 2021-01-25 16:18

    If you really wanted to, just use Connections.Connection[UserName]. That returns the same SqlConnection. However that will dispose it. Your pattern/design is flawed because ADO.NET has connection pooling.

    You could also add your own wrapping object that implements IDisposable.

    0 讨论(0)
提交回复
热议问题