System.Data.SqlClient.SqlExceptionExtensions.IsConnectionClosed C# (CSharp) Метод

IsConnectionClosed() публичный статический Метод

Determines whether SqlConnection will be closed when this exception is raised.
The SqlConnection remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the SqlConnection. (source=http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlexception.aspx)
public static IsConnectionClosed ( this exception ) : bool
exception this The exception.
Результат bool
        public static bool IsConnectionClosed(this SqlException exception)
        {
            Contract.Requires(exception != null);

            for (int i = 0; i < exception.Errors.Count; i++)
            {
                if (20 <= exception.Errors[i].Class)
                {
                    return true;
                }
            }

            return false;
        }