在返回"命令"之前如何处理它而不影响返回类型
"Reability error CA2000(CA2000:在丢失作用域之前处理对象)"
SqlCommand command = new SqlCommand(sqlCmd);
command.CommandTimeout = 240;
if (applicationId == int.MinValue)
command.Parameters.AddWithValue("@ApplicationId", DBNull.Value);
else
command.Parameters.AddWithValue("@ApplicationId", applicationId);
return DB.ExecuteDataset(command);
Jeapordy风格:"什么是using
语句?"
using(SqlCommand command = new SqlCommand(sqlCmd))
{
command.CommandTimeout = 240;
if (applicationId == int.MinValue)
command.Parameters.AddWithValue("@ApplicationId", DBNull.Value);
else
command.Parameters.AddWithValue("@ApplicationId", applicationId);
return DB.ExecuteDataset(command);
}