Esempio n. 1
0
        /// <summary>
        /// Creates a SqlExceptionMapper with default converters for SQL Server.
        /// </summary>
        public static SqlExceptionMapper Default()
        {
            var mappings = new List <SqlExceptionMapping> {
                SqlExceptionMapping.MatchOnSqlErrorCode(
                    new[] { 2627, 2601, 547 },
                    c => new ConstraintViolationException(c.SqlException.Message, c.SqlException.InnerException, c.Sql, null)
                    ),
                SqlExceptionMapping.MatchOnSqlErrorCode(
                    new[] { 208 },
                    c => new SQLGrammarException(c.SqlException.Message, c.SqlException.InnerException, c.Sql)
                    ),
                SqlExceptionMapping.MatchOnSqlErrorCode(
                    new[] { 3960 },
                    c => new StaleObjectStateException(c.EntityName, c.EntityId)
                    )
            };

            return(new SqlExceptionMapper(mappings));
        }
Esempio n. 2
0
 /// <summary>
 /// Adds a mapping rule to the end of the list.
 /// </summary>
 public void AddExceptionMappingToEnd(SqlExceptionMapping mapping)
 {
     _mappings.Add(mapping);
 }
Esempio n. 3
0
 /// <summary>
 /// Adds a mapping rule to the top of the list.
 /// </summary>
 public void AddExceptionMappingToTop(SqlExceptionMapping mapping)
 {
     _mappings.Insert(0, mapping);
 }