/// <summary> /// Initializes a new instance of the SqlSchemaError for a repairable field level error. /// </summary> /// <param name="errorType">a type of the error (inconsistency)</param> /// <param name="description">a description of the error (inconsistency) (must be specified)</param> /// <param name="table">the name of the database table which field is inconsistent (must be specified)</param> /// <param name="field">the name of the database field that is inconsistent</param> /// <param name="sqlStatementsToRepair">a collection of the SQL statements /// that should be issued to repair the error (must be specified)</param> /// <exception cref="ArgumentNullException">Error description is not specified.</exception> /// <exception cref="ArgumentNullException">Error table is not specified.</exception> /// <exception cref="ArgumentNullException">SQL statements to repair the error is not specified.</exception> /// <exception cref="ArgumentException">No SQL statement could be empty.</exception> internal DbSchemaError(DbSchemaErrorType errorType, string description, string table, string field, string[] sqlStatementsToRepair) { if (description.IsNullOrWhiteSpace()) { throw new ArgumentNullException(nameof(description)); } if (table.IsNullOrWhiteSpace()) { throw new ArgumentNullException(nameof(table)); } if (null == sqlStatementsToRepair || sqlStatementsToRepair.Length < 1) { throw new ArgumentNullException(nameof(sqlStatementsToRepair)); } ValidateSqlStatements(sqlStatementsToRepair); _errorType = errorType; _description = description.Trim(); _table = table?.Trim() ?? string.Empty; _field = field?.Trim() ?? string.Empty; _sqlStatementsToRepair = sqlStatementsToRepair; _isRepairable = true; }
/// <summary> /// Initializes a new instance of the SqlSchemaError for an unrepairable error. /// </summary> /// <param name="errorType">a type of the error (inconsistency)</param> /// <param name="description">a description of the error (inconsistency) (must be specified)</param> /// <param name="table">the name of the database table which field is inconsistent</param> /// <param name="field">the name of the database field that is inconsistent</param> /// <exception cref="ArgumentNullException">Error description is not specified.</exception> internal DbSchemaError(DbSchemaErrorType errorType, string description, string table, string field) { if (description.IsNullOrWhiteSpace()) { throw new ArgumentNullException(nameof(description)); } _errorType = errorType; _description = description.Trim(); _table = table?.Trim() ?? string.Empty; _field = field?.Trim() ?? string.Empty; _sqlStatementsToRepair = new string[] {}; _isRepairable = false; }
/// <summary> /// Gets a new instance of the SqlSchemaError for an unrepairable error. /// </summary> /// <param name="errorType">a type of the error (inconsistency)</param> /// <param name="description">a description of the error (inconsistency) (must be specified)</param> /// <param name="table">the name of the database table which field is inconsistent</param> /// <param name="field">the name of the database field that is inconsistent</param> /// <exception cref="ArgumentNullException">Error description is not specified.</exception> protected DbSchemaError GetUnrepairableDbSchemaError(DbSchemaErrorType errorType, string description, string table, string field) { return(new DbSchemaError(errorType, description, table, field)); }
/// <summary> /// Gets a new instance of the SqlSchemaError for a repairable database level error. /// </summary> /// <param name="errorType">a type of the error (inconsistency)</param> /// <param name="description">a description of the error (inconsistency) (must be specified)</param> /// <param name="sqlStatementsToRepair">a collection of the SQL statements /// that should be issued to repair the error (must be specified)</param> /// <exception cref="ArgumentNullException">Error description is not specified.</exception> /// <exception cref="ArgumentNullException">Error table is not specified.</exception> /// <exception cref="ArgumentNullException">SQL statements to repair the error is not specified.</exception> /// <exception cref="ArgumentException">No SQL statement could be empty.</exception> protected DbSchemaError GetDbSchemaError(DbSchemaErrorType errorType, string description, string[] sqlStatementsToRepair) { return(new DbSchemaError(errorType, description, sqlStatementsToRepair)); }
/// <summary> /// Initializes a new instance of the SqlSchemaError for a repairable table level error. /// </summary> /// <param name="errorType">a type of the error (inconsistency)</param> /// <param name="description">a description of the error (inconsistency) (must be specified)</param> /// <param name="table">the name of the database table which schema is inconsistent (must be specified)</param> /// <param name="sqlStatementsToRepair">a collection of the SQL statements /// that should be issued to repair the error (must be specified)</param> /// <exception cref="ArgumentNullException">Error description is not specified.</exception> /// <exception cref="ArgumentNullException">Error table is not specified.</exception> /// <exception cref="ArgumentNullException">SQL statements to repair the error is not specified.</exception> /// <exception cref="ArgumentException">No SQL statement could be empty.</exception> internal DbSchemaError(DbSchemaErrorType errorType, string description, string table, string[] sqlStatementsToRepair) : this(errorType, description, table, string.Empty, sqlStatementsToRepair) { }