当前位置: 首页>>代码示例>>C#>>正文


C# Exceptions.AdoExceptionContextInfo类代码示例

本文整理汇总了C#中NHibernate.Exceptions.AdoExceptionContextInfo的典型用法代码示例。如果您正苦于以下问题:C# AdoExceptionContextInfo类的具体用法?C# AdoExceptionContextInfo怎么用?C# AdoExceptionContextInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AdoExceptionContextInfo类属于NHibernate.Exceptions命名空间,在下文中一共展示了AdoExceptionContextInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert

        public Exception Convert(AdoExceptionContextInfo exInfo)
        {
            var dbException = ADOExceptionHelper.ExtractDbException(exInfo.SqlException);

              var ns = dbException.GetType().Namespace ?? string.Empty;
              if (ns.ToLowerInvariant().StartsWith("system.data.sqlite"))
              {
            // SQLite exception
            switch (dbException.ErrorCode)
            {
              case -2147467259: // Abort due to constraint violation
            throw new ConcurrencyException();
            }
              }

              if (ns.ToLowerInvariant().StartsWith("system.data.sqlclient"))
              {
            // MS SQL Server
            switch (dbException.ErrorCode)
            {
              case -2146232060:
            throw new ConcurrencyException();
            }
              }

              return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException,
              exInfo.Message, exInfo.Sql);
        }
开发者ID:jasondentler,项目名称:gregyoung-simple-cqrs,代码行数:28,代码来源:SqlExceptionConverter.cs

示例2: Convert

        public Exception Convert(AdoExceptionContextInfo adoExceptionContextInfo)
        {
            DbException sqlException = ADOExceptionHelper.ExtractDbException(adoExceptionContextInfo.SqlException);
            string message = adoExceptionContextInfo.Message;
            string sql = adoExceptionContextInfo.Sql;

            int errorCode = (int)sqlException.GetType().GetProperty("NativeError").GetValue(sqlException, null);

            if (errorCode >= 1 && errorCode <= 90)
            {
                return new SQLGrammarException(message, sqlException, sql);
            }

            if (integrityViolationCategories.Contains(errorCode))
            {
                string constraintName = extracter.ExtractConstraintName(sqlException);
                return new ConstraintViolationException(message, sqlException, sql, constraintName);
            }

            if (connectionCategories.Contains(errorCode))
            {
                return new ADOConnectionException(message, sqlException, sql);
            }

            if (dataCategories.Contains(errorCode))
            {
                return new DataException(message, sqlException, sql);
            }

            return HandledNonSpecificException(sqlException, message, sql);
        }
开发者ID:mnjstwins,项目名称:NHibernate.CacheDb,代码行数:31,代码来源:CacheSQLStateConverter.cs

示例3: Convert

            public Exception Convert(AdoExceptionContextInfo contextInfo)
            {
                Exception result = null;
                var sqle = ADOExceptionHelper.ExtractDbException(contextInfo.SqlException) as SqlException;
                if (sqle != null)
                {
                    switch (sqle.Number)
                    {
                        case 547:
                            result = new ConstraintViolationException(
                                sqle.Message,
                                sqle,
                                contextInfo.Sql,
                                null);
                            break;
                        case 208:
                            result = new SQLGrammarException(
                                contextInfo.Message,
                                sqle,
                                contextInfo.Sql);
                            break;
                        case 3960:
                            result = new StaleObjectStateException(
                                contextInfo.EntityName,
                                contextInfo.EntityId);
                            break;
                    }
                }

                return result ?? SQLStateConverter.HandledNonSpecificException(
                    contextInfo.SqlException,
                    contextInfo.Message,
                    contextInfo.Sql);
            }
开发者ID:quadio,项目名称:amss-boilerplate,代码行数:34,代码来源:MsSql2005DatabaseConfigurator.cs

示例4: Convert

        /// <summary>
        ///     Converts the db specific exceptions to something more usable.
        /// </summary>
        /// <param name="exInfo">The exception info.</param>
        /// <returns>Exception thrown</returns>
        public System.Exception Convert(AdoExceptionContextInfo exInfo)
        {
            var sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as SqlException;
            var finalException = Convert(sqle, exInfo);

            return finalException;
        }
开发者ID:phucls,项目名称:ara,代码行数:12,代码来源:SQLServerExceptionConverter.cs

示例5: Convert

        public Exception Convert(AdoExceptionContextInfo exInfo)
        {
            var sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as SqlException;
            if (sqle != null)
            {
                switch (sqle.Number)
                {
                case 17:
                    // SQL Server does not exist or access denied.
                case 4060:
                    // Invalid Database
                case 18456:
                    // Login Failed
                    return new DatabaseException(sqle.Message, sqle);
                case 547:
                    // ForeignKey Violation
                    return new ConstraintException(_ParseConstraintName(sqle.Message), sqle);
                case 1205:
                    // DeadLock Victim
                    return new DatabaseException(sqle.Message, sqle);
                case 2627:
                case 2601:
                    // Unique Index/Constriant Violation
                    return new ConstraintException(_ParseConstraintName(sqle.Message), sqle);
                default:
                    // throw a general DAL Exception
                    return new DatabaseException(sqle.Message, sqle);
                }
            }

            return SQLStateConverter.HandledNonSpecificException(
                       exInfo.SqlException,
                       exInfo.Message, exInfo.Sql);
        }
开发者ID:OscarNET,项目名称:Hexa.Core,代码行数:34,代码来源:SqlExceptionHandler.cs

示例6: Convert

        public Exception Convert(AdoExceptionContextInfo exInfo)
        {
            //var dbException = ADOExceptionHelper.ExtractDbException(exInfo.SqlException);
            //var textoResource = String.Empty;


            //// SQLite exception
            //switch (dbException.ErrorCode)
            //{
            //    case 2601://Cannot insert duplicate key row in object '%.*ls' with unique index '%.*ls'. The duplicate key value is %ls.
            //        textoResource = _resource.GetString("DadoDuplicadoNaoPermitido"); //Repetição não permitida para o campo {0}.
            //        //return new BusinessException(campo, erro);//DadoDuplicadoNaoPermitido

            //    case 233:
            //        textoResource = _resource.GetString("ValorNuloNaoPermitido");
            //        //return new BusinessException(campo, erro);//DadoDuplicadoNaoPermitido


            //    default:
            //        throw new InvalidOperationException(String.Format("ExtendedError {0} não mapeado", erro));

            //}

            throw new NotImplementedException();

        }
开发者ID:TicketArchitecture,项目名称:Api-Template,代码行数:26,代码来源:SQLServerSqlExceptionConverter.cs

示例7: Convert

		public Exception Convert(AdoExceptionContextInfo exInfo)
		{
			var sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as SqlException;
			if ((sqle != null) && (sqle.Number == 3960))
			{
				return new StaleObjectStateException(exInfo.EntityName, exInfo.EntityId);
			}
			return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message, exInfo.Sql);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:9,代码来源:SQLUpdateConflictToStaleStateExceptionConverter.cs

示例8: Convert

		public Exception Convert(AdoExceptionContextInfo exceptionInfo)
		{
			/*
			 * So far I know we don't have something similar to "X/Open-compliant SQLState" in .NET
			 * This mean that each Dialect must have its own ISQLExceptionConverter, overriding BuildSQLExceptionConverter method,
			 * and its own IViolatedConstraintNameExtracter if needed.
			 * The System.Data.Common.DbException, of .NET2.0, don't give us something applicable to all dialects.
			 */
			return HandledNonSpecificException(exceptionInfo.SqlException, exceptionInfo.Message, exceptionInfo.Sql);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:10,代码来源:SQLStateConverter.cs

示例9: Convert

		public static Exception Convert(ISQLExceptionConverter converter, AdoExceptionContextInfo exceptionContextInfo)
		{
			if(exceptionContextInfo == null)
			{
				throw new AssertionFailure("The argument exceptionContextInfo is null.");
			}
			var sql = TryGetActualSqlQuery(exceptionContextInfo.SqlException, exceptionContextInfo.Sql);
			ADOExceptionReporter.LogExceptions(exceptionContextInfo.SqlException,
			                                   ExtendMessage(exceptionContextInfo.Message, sql, null, null));
			return converter.Convert(exceptionContextInfo);
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:11,代码来源:ADOExceptionHelper.cs

示例10: Convert

		public Exception Convert(AdoExceptionContextInfo exInfo)
		{
			SqlException sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as SqlException;
			if(sqle != null)
			{
				if (sqle.Number == 547)
					return new ConstraintViolationException(exInfo.Message, sqle.InnerException, exInfo.Sql, null);
				if (sqle.Number == 208)
					return new SQLGrammarException(exInfo.Message, sqle.InnerException, exInfo.Sql);
			}
			return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message, exInfo.Sql);
		}
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:12,代码来源:MSSQLExceptionConverterExample.cs

示例11: Convert

		public Exception Convert(AdoExceptionContextInfo exInfo)
		{
			var sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as OracleException;
			if (sqle != null)
			{
				if (sqle.Code == 1036)
				{
					return new ConstraintViolationException(exInfo.Message, sqle.InnerException, exInfo.Sql, null);
				}
				if (sqle.Code == 942)
				{
					return new SQLGrammarException(exInfo.Message, sqle.InnerException, exInfo.Sql);
				}
			}
			return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message, exInfo.Sql);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:16,代码来源:OracleClientExceptionConverterExample.cs

示例12: Convert

		public Exception Convert(AdoExceptionContextInfo adoExceptionContextInfo)
		{
			var sqle = ADOExceptionHelper.ExtractDbException(adoExceptionContextInfo.SqlException) as DbException;
			if (sqle != null)
			{
				if (sqle.ErrorCode == 335544466)
				{
					return new ConstraintViolationException(adoExceptionContextInfo.Message, sqle.InnerException, adoExceptionContextInfo.Sql, null);
				}
				if (sqle.ErrorCode == 335544569)
				{
					return new SQLGrammarException(adoExceptionContextInfo.Message, sqle.InnerException, adoExceptionContextInfo.Sql);
				}
			}
			return SQLStateConverter.HandledNonSpecificException(adoExceptionContextInfo.SqlException, adoExceptionContextInfo.Message, adoExceptionContextInfo.Sql);
		}
开发者ID:rosieks,项目名称:nhibernate-core,代码行数:16,代码来源:FbExceptionConverterExample.cs

示例13: Convert

		public Exception Convert(AdoExceptionContextInfo exInfo)
		{
			var sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as DbException;
			if (sqle != null)
			{
				string code = (string)sqle.GetType().GetProperty("Code").GetValue(sqle, null);

				if (code == "23503")
				{
					return new ConstraintViolationException(exInfo.Message, sqle.InnerException, exInfo.Sql, null);
				}
				if (code == "42P01")
				{
					return new SQLGrammarException(exInfo.Message, sqle.InnerException, exInfo.Sql);
				}
			}
			return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message, exInfo.Sql);
		}
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:18,代码来源:PostgresExceptionConverterExample.cs

示例14: Convert

 /// <summary>
 /// 转换
 /// </summary>
 /// <param name="adoExceptionContextInfo"></param>
 /// <returns></returns>
 public Exception Convert(AdoExceptionContextInfo adoExceptionContextInfo)
 {
     var sqle = ADOExceptionHelper.ExtractDbException(adoExceptionContextInfo.SqlException) as SqlException;
     if (sqle != null)
     {
         switch (sqle.Number)
         {
             case 547:
             case 2627:
                 return new ConstraintViolationException(adoExceptionContextInfo.SqlException.Message,
                     null, adoExceptionContextInfo.Sql, null);
             case 208:
                 return new SQLGrammarException(adoExceptionContextInfo.SqlException.Message,
                     null, adoExceptionContextInfo.Sql);
             case 3960:
                 return new StaleObjectStateException(adoExceptionContextInfo.EntityName, adoExceptionContextInfo.EntityId);
         }
     }
     return SQLStateConverter.HandledNonSpecificException(adoExceptionContextInfo.SqlException,
         adoExceptionContextInfo.SqlException.Message, adoExceptionContextInfo.Sql);
 }
开发者ID:urmilaNominate,项目名称:mERP-framework,代码行数:26,代码来源:MsSqlExceptionConverter.cs

示例15: Convert

        public Exception Convert(AdoExceptionContextInfo exInfo)
        {
            var dbException = ADOExceptionHelper.ExtractDbException(exInfo.SqlException);


            var erro = ErrorDescription(dbException.Message);
            var campo = SQLiteErrorField(dbException.Message);


            // SQLite exception
            switch (dbException.ErrorCode)
            {
                case 19: // violação de constraint
                    return WorkOnExtendedError(erro, campo);

                default:
                    throw new InvalidOperationException(String.Format("Error code {0} não mapeado", dbException.ErrorCode));
                    //return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException,
                    //exInfo.Message, exInfo.Sql);

            }


        }
开发者ID:TicketArchitecture,项目名称:Api-Template,代码行数:24,代码来源:SQLiteSqlExceptionConverter.cs


注:本文中的NHibernate.Exceptions.AdoExceptionContextInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。