应该关闭ReliableSqlConnection的SQLConnection吗?

时间:2016-04-03 13:32:29

标签: c# azure-sql-database

我在使用// In MyParentComponent componentDidUpdate(prevProps, prevState) { if (prevState.valueSelected !== this.state.valueSelected) this.refs.myInput.value = ''; // Do this for each input, you'll need to add a unique ref attribute for each one } ... 时找到的每个示例都类似于:

ReliableSqlConnection

using (var cnn = new ReliableSqlConnection(connString)) { using (var cmd = cnn.CreateCommand()) { cnn.Open(); ... } } 返回Open() SQLConnection时,是否应该处理?

如果我将其封装在using语句中,会不会产生任何影响或伤害?

IDisposable

1 个答案:

答案 0 :(得分:0)

您无需处置,已弃用的 ReliableSQLConnection类会在其ctor中创建SqlConnection并将其置于其Dispose()中:

private void Dispose(bool disposing)
{
    if (disposing)
    {
        if (this.underlyingConnection.State == ConnectionState.Open)
        {
            this.underlyingConnection.Close();
        }

        this.underlyingConnection.Dispose();
    }
}
相关问题