public static bool IsInvalidObjectNameError(
        this EntityCommandExecutionException exception)
    {
        const int InvalidObjectName = 208;
        var       sqlException      = exception.InnerException as SqlException;

        if (sqlException == null)
        {
            return(false);
        }
        return(sqlException.Errors.Cast <SqlError>().Any(
                   error => error.Number == InvalidObjectName));
    }
예제 #2
0
        /// <summary>
        /// Checks whether the inner exception indicates a deadlock error
        /// </summary>
        /// <param name="exception">The exception wrapper</param>
        /// <returns></returns>
        public static bool IsDeadlockException(this EntityCommandExecutionException exception)
        {
            var sqlException = exception?.InnerException as SqlException;

            if (sqlException == null)
            {
                sqlException = exception?.InnerException?.InnerException as SqlException;
            }

            if (sqlException == null)
            {
                return(false);
            }

            return(sqlException.IsDeadlockException());
        }
예제 #3
0
        private static string[] GenerateSqlErrorMessage(EntityCommandExecutionException exeception)
        {
            var ex = (SqlException)exeception.InnerException;
            String[] errorMessages = new string[ex.Errors.Count];
            for (int i = 0; i < ex.Errors.Count; i++)
            {
                errorMessages[i] = "Index #" + i + "\n" +
                    "Message: " + ex.Errors[i].Message + "\n" +
                    "LineNumber: " + ex.Errors[i].LineNumber + "\n" +
                    "Number: " + ex.Errors[i].Number + "\n" +
                    "Source: " + ex.Errors[i].Source + "\n" +
                    "Procedure: " + ex.Errors[i].Procedure + "\n";
            }

            return errorMessages;
        }