the associated Connection object is closed when the associated DataReader object is closed.
since you are not closing data reader before return there is no affect using CommandBehavior.CloseConnection
but your using
block will close the connection.
I would add using
blocks for both SqlCommand
and Reader
as well
using (var con = new SqlConnection(_constr))
using (var cmd = new SqlCommand(cmdstr, con))
{
con.Open();
using (var reader = cmd.ExecuteReader())
{
if (reader.Read())
return Convert.ToInt32(reader["persianDate"].ToString());
}
}