Duwamish中DataAccess.Customers在实现DISPOSE来释放对象的实例变量时为什么只是释放dsCommand,而没有释放insertCommand,updateCommand?
Duwamish中DataAccess.Customers在实现DISPOSE来释放对象的实例变量时为什么只是释放(SqldataAdapter)dsCommand的CONNECTION等,而没有释放(SqlCommand)insertCommand,updateCommand和它们的CONNECTION?以下部份代码:
private SqlDataAdapter dsCommand;
private SqlCommand loadCommand;
private SqlCommand insertCommand;
private SqlCommand updateCommand; /// <summary>
/// Free the instance variables of this object.
/// </summary>
protected virtual void Dispose(bool disposing)
{
if (! disposing)
return; // we're being collected, so let the GC take care of this object if (dsCommand != null)
{
if(dsCommand.SelectCommand != null)
{
if( dsCommand.SelectCommand.Connection != null )
{
dsCommand.SelectCommand.Connection.Dispose();
}
dsCommand.SelectCommand.Dispose();
}
dsCommand.Dispose();
dsCommand = null;
}
}
private SqlDataAdapter dsCommand;
private SqlCommand loadCommand;
private SqlCommand insertCommand;
private SqlCommand updateCommand; /// <summary>
/// Free the instance variables of this object.
/// </summary>
protected virtual void Dispose(bool disposing)
{
if (! disposing)
return; // we're being collected, so let the GC take care of this object if (dsCommand != null)
{
if(dsCommand.SelectCommand != null)
{
if( dsCommand.SelectCommand.Connection != null )
{
dsCommand.SelectCommand.Connection.Dispose();
}
dsCommand.SelectCommand.Dispose();
}
dsCommand.Dispose();
dsCommand = null;
}
}
dsCommand.SelectCommand.Dispose();