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


C# ConvertType类代码示例

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


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

示例1: Convert

		public override object Convert(object value, ConvertType convertType)
		{
			switch (convertType)
			{
				case ConvertType.NameToCommandParameter:
				case ConvertType.NameToSprocParameter:
					return ParameterPrefix == null? value: ParameterPrefix + value;

				case ConvertType.SprocParameterToName:
					var name = (string)value;

					if (name.Length > 0)
					{
						if (name[0] == ':')
							return name.Substring(1);

						if (ParameterPrefix != null &&
							name.ToUpper(CultureInfo.InvariantCulture).StartsWith(ParameterPrefix))
						{
							return name.Substring(ParameterPrefix.Length);
						}
					}

					break;

				case ConvertType.ExceptionToErrorNumber:
					if (value is OracleException)
						return ((OracleException)value).Code;
					break;
			}

			return SqlProvider.Convert(value, convertType);
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:33,代码来源:OracleDataProvider.cs

示例2: Convert

		public override object Convert(object value, ConvertType convertType)
		{
			string name = (string)value;

			switch (convertType)
			{
				case ConvertType.NameToQueryParameter:
				case ConvertType.NameToParameter:
					return "@" + name;

				case ConvertType.NameToQueryField:
				case ConvertType.NameToQueryTable:

					if (name.Length > 0 && name[0] == '[')
						return value;

					if (name.IndexOf('.') > 0)
						value = string.Join("].[", name.Split('.'));

					return "[" + value + "]";

				case ConvertType.ParameterToName:
					return name.Length > 0 && name[0] == '@'? name.Substring(1): name;

				case ConvertType.ExceptionToErrorNumber:
					if (value is SQLiteException)
						return ((SQLiteException)value).ErrorCode;
					break;
			}

			return value;
		}
开发者ID:epdumitru,项目名称:mysqlib,代码行数:32,代码来源:SQLiteDataProvider.cs

示例3: Convert

        public override object Convert(object value, ConvertType convertType)
        {
            switch (convertType)
            {
                case ConvertType.NameToQueryField:
                case ConvertType.NameToQueryTable:
                    if (QuoteIdentifiers)
                    {
                        string name = value.ToString();

                        if (name.Length > 0 && name[0] == '"')
                            return value;

                        return '"' + name + '"';
                    }

                    break;

                case ConvertType.NameToQueryParameter:
                case ConvertType.NameToCommandParameter:
                case ConvertType.NameToSprocParameter:
                    return "@" + value;

                case ConvertType.SprocParameterToName:
                    if (value != null)
                    {
                        string str = value.ToString();
                        return str.Length > 0 && str[0] == '@' ? str.Substring(1) : str;
                    }

                    break;
            }

            return value;
        }
开发者ID:henleygao,项目名称:linq2db,代码行数:35,代码来源:FirebirdSqlProvider.cs

示例4: Convert

		public override object Convert(object value, ConvertType convertType)
		{
			switch (convertType)
			{
				case ConvertType.NameToQueryParameter:
				case ConvertType.NameToCommandParameter:
				case ConvertType.NameToSprocParameter:
					return "@" + value;

				case ConvertType.NameToQueryField:
				case ConvertType.NameToQueryFieldAlias:
				case ConvertType.NameToQueryTableAlias:
					{
						var name = value.ToString();

						if (name.Length > 0 && name[0] == '[')
							return value;
					}

					return "[" + value + "]";

				case ConvertType.NameToDatabase:
				case ConvertType.NameToOwner:
				case ConvertType.NameToQueryTable:
					{
						var name = value.ToString();

						if (name.Length > 0 && name[0] == '[')
							return value;

						if (name.IndexOf('.') > 0)
							value = string.Join("].[", name.Split('.'));
					}

					return "[" + value + "]";

				case ConvertType.SprocParameterToName:
					if (value != null)
					{
						var str = value.ToString();
						return str.Length > 0 && str[0] == '@'? str.Substring(1): str;
					}

					break;

				case ConvertType.ExceptionToErrorNumber:
					if (value is OleDbException)
					{
						var ex = (OleDbException)value;
						if (ex.Errors.Count > 0)
							return ex.Errors[0].NativeError;
					}

					break;
			}

			return value;
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:58,代码来源:OleDbDataProvider.cs

示例5: Convert

        public override object Convert(object value, ConvertType convertType)
        {
            switch (convertType)
            {
                case ConvertType.NameToQueryParameter:
                case ConvertType.NameToCommandParameter:
                case ConvertType.NameToSprocParameter:
                    {
                        var name = "@" + value;

                        if (name.Length > 27)
                            name = name.Substring(0, 27);

                        return name;
                    }

                case ConvertType.NameToQueryField:
                case ConvertType.NameToQueryFieldAlias:
                case ConvertType.NameToQueryTableAlias:
                    {
                        var name = value.ToString();

                        if (name.Length > 28 || name.Length > 0 && name[0] == '[')
                            return value;
                    }

                    return "[" + value + "]";

                case ConvertType.NameToDatabase:
                case ConvertType.NameToOwner:
                case ConvertType.NameToQueryTable:
                    if (value != null)
                    {
                        var name = value.ToString();

                        if (name.Length > 28 || name.Length > 0 && (name[0] == '[' || name[0] == '#'))
                            return value;

                        if (name.IndexOf('.') > 0)
                            value = string.Join("].[", name.Split('.'));

                        return "[" + value + "]";
                    }

                    break;

                case ConvertType.SprocParameterToName:
                    if (value != null)
                    {
                        var str = value.ToString();
                        return str.Length > 0 && str[0] == '@'? str.Substring(1): str;
                    }

                    break;
            }

            return value;
        }
开发者ID:henleygao,项目名称:linq2db,代码行数:58,代码来源:SybaseSqlProvider.cs

示例6: Convert

        public override object Convert(object value, ConvertType convertType)
        {
            switch (convertType)
            {
                case ConvertType.NameToQueryParameter:
                    return ":" + value;
            }

            return value;
        }
开发者ID:pebezo,项目名称:linq2db,代码行数:10,代码来源:OracleSqlBuilder.cs

示例7: Convert

		public override object Convert(object value, ConvertType convertType)
		{
			switch (convertType)
			{
				case ConvertType.NameToQueryParameter:
				case ConvertType.NameToParameter:
					return "@" + value;

				case ConvertType.NameToQueryField:
					{
						string name = value.ToString();

						if (name.Length > 0 && name[0] == '[')
							return value;
					}

					return "[" + value + "]";

				case ConvertType.NameToQueryTable:
					{
						string name = value.ToString();

						if (name.Length > 0 && name[0] == '[')
							return value;

						if (name.IndexOf('.') > 0)
							value = string.Join("].[", name.Split('.'));
					}

					return "[" + value + "]";

				case ConvertType.ParameterToName:
					if (value != null)
					{
						string str = value.ToString();
						return str.Length > 0 && str[0] == '@'? str.Substring(1): str;
					}

					break;

				case ConvertType.ExceptionToErrorNumber:
					if (value is AseException)
					{
						AseException ex = (AseException)value;

						if (ex.Errors.Count > 0)
							return ex.Errors[0].MessageNumber;
					}

					break;
			}

			return value;
		}
开发者ID:epdumitru,项目名称:mysqlib,代码行数:54,代码来源:SybaseDataProvider.cs

示例8: Convert

		public override object Convert(object value, ConvertType convertType)
		{
			if (ConvertType.NameToQueryField == convertType)
			{
				return FieldMarker + value;
			}
			if (ConvertType.NameToQueryTable == convertType)
			{
				return TableMarker + value;
			}
			return base.Convert(value, convertType);
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:12,代码来源:MockSqlProvider.cs

示例9: Convert

		public override object Convert(object value, ConvertType convertType)
		{
			switch (convertType)
			{
				case ConvertType.ExceptionToErrorNumber:
					if (value is SqlCeException)
						return ((SqlCeException)value).NativeError;
					break;
			}

			return SqlProvider.Convert(value, convertType);
		}
开发者ID:kekekeks,项目名称:bltoolkit,代码行数:12,代码来源:SqlCeDataProvider.cs

示例10: Convert

		public override object Convert(object value, ConvertType convertType)
		{
			switch (convertType)
			{
				case ConvertType.NameToQueryParameter:
					return "?";

				case ConvertType.NameToParameter:
					return value;
			}

			return base.Convert(value, convertType);
		}
开发者ID:epdumitru,项目名称:mysqlib,代码行数:13,代码来源:SybaseAdoDataProvider.cs

示例11: Convert

        public override object Convert(object value, ConvertType convertType)
        {
            switch (convertType)
            {
                case ConvertType.ExceptionToErrorNumber:
                    {
                        if (value is SQLiteException)
                            return ((SQLiteException) value).ErrorCode;
                        break;
                    }
            }

            return SqlProvider.Convert(value, convertType);
        }
开发者ID:qrunner,项目名称:Default,代码行数:14,代码来源:SQLiteDataProvider.cs

示例12: Convert

		public override object Convert(object value, ConvertType convertType)
		{
			switch (convertType)
			{
				case ConvertType.ExceptionToErrorNumber:
					if (value is OdbcException)
					{
						OdbcException ex = (OdbcException)value;
						if (ex.Errors.Count > 0)
							return ex.Errors[0].NativeError;
					}
					break;
			}

			return base.Convert(value, convertType);
		}
开发者ID:epdumitru,项目名称:mysqlib,代码行数:16,代码来源:OdbcDataProvider.cs

示例13: Convert

        public override object Convert(object value, ConvertType convertType)
        {
            switch (convertType)
            {
                case ConvertType.NameToQueryParameter:
                    return "@" + value;

                case ConvertType.NameToCommandParameter:
                case ConvertType.NameToSprocParameter:
                    return ":" + value;

                case ConvertType.SprocParameterToName:
                    if (value != null)
                    {
                        var str = value.ToString();
                        return str.Length > 0 && str[0] == ':'? str.Substring(1): str;
                    }

                    break;

                case ConvertType.NameToQueryField:
                case ConvertType.NameToQueryFieldAlias:
                case ConvertType.NameToQueryTable:
                case ConvertType.NameToQueryTableAlias:
                    if (value != null && IdentifierQuoteMode != DB2IdentifierQuoteMode.None)
                    {
                        var name = value.ToString();

                        if (name.Length > 0 && name[0] == '"')
                            return name;

                        if (IdentifierQuoteMode == DB2IdentifierQuoteMode.Quote ||
                            name.StartsWith("_") ||
                            name
            #if NETFX_CORE
                                .ToCharArray()
            #endif
                                .Any(c => char.IsLower(c) || char.IsWhiteSpace(c)))
                            return '"' + name + '"';
                    }

                    break;
            }

            return value;
        }
开发者ID:pebezo,项目名称:linq2db,代码行数:46,代码来源:DB2SqlBuilderBase.cs

示例14: Convert

        public override object Convert(object value, ConvertType convertType)
        {
            switch (convertType)
            {
                case ConvertType.NameToQueryParameter   : return "?";
                case ConvertType.NameToCommandParameter :
                case ConvertType.NameToSprocParameter   : return ":" + value;
                case ConvertType.SprocParameterToName   :
                    if (value != null)
                    {
                        var str = value.ToString();
                        return (str.Length > 0 && str[0] == ':')? str.Substring(1): str;
                    }

                    break;
            }

            return value;
        }
开发者ID:jogibear9988,项目名称:linq2db,代码行数:19,代码来源:InformixSqlProvider.cs

示例15: Convert

		public override object Convert(object value, ConvertType convertType)
		{
			switch (convertType)
			{
				case ConvertType.ExceptionToErrorNumber:
					if (value is NpgsqlException)
					{
						var ex = (NpgsqlException)value;

						foreach (NpgsqlError error in ex.Errors)
							return error.Code;

						return 0;
					}

					break;
			}

			return SqlProvider.Convert(value, convertType);
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:20,代码来源:PostgreSQLDataProvider.cs


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