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


C# DbType.ToString方法代码示例

本文整理汇总了C#中DbType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DbType.ToString方法的具体用法?C# DbType.ToString怎么用?C# DbType.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbType的用法示例。


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

示例1: DbTypeToString

 public virtual string DbTypeToString(DbType type, int size, int precision)
 {
     var s = new StringBuilder(type.ToString().ToLower());
     if (0 < size)
     {
         s.AppendFormat(0 < precision ? "({0}, {1})" : "({0})", size, precision);
     }
     return s.ToString();
 }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:9,代码来源:SqlDialect.cs

示例2: GetDbQuery

 public static DbQuery GetDbQuery(DbType dbType)
 {
     switch (dbType)
     {
         case DbType.MSSqlServer2005:
             return new MSSql2005Query();
         default:
             throw new ArgumentException("不支持此数据库类型。 - " + dbType.ToString());
     }
 }
开发者ID:NoobSkie,项目名称:taobao-shop-helper,代码行数:10,代码来源:DbQuery.cs

示例3: DbTypeToSqlDbType

 /// <summary>
 /// Dbs the type of the type to SQL db.
 /// </summary>
 /// <param name="dbType">Type of the db.</param>
 /// <returns>Sql Db Type.</returns>
 public static SqlDbType DbTypeToSqlDbType(DbType dbType) {
     switch (dbType) {
         case DbType.AnsiString: return SqlDbType.VarChar;
         case DbType.Binary: return SqlDbType.VarBinary;
         case DbType.Byte: return SqlDbType.TinyInt;
         case DbType.Boolean: return SqlDbType.Bit;
         case DbType.Currency: return SqlDbType.Money;
         case DbType.Date: return SqlDbType.DateTime;
         case DbType.DateTime: return SqlDbType.DateTime;
         case DbType.Decimal: return SqlDbType.Decimal;
         case DbType.Double: return SqlDbType.Float;
         case DbType.Guid: return SqlDbType.UniqueIdentifier;
         case DbType.Int16: return SqlDbType.SmallInt;
         case DbType.Int32: return SqlDbType.Int;
         case DbType.Int64: return SqlDbType.BigInt;
         case DbType.Object: return SqlDbType.Variant;
         case DbType.SByte: throw new NotSupportedException(dbType.ToString());
         case DbType.Single: return SqlDbType.Real;
         case DbType.String: return SqlDbType.NVarChar;
         case DbType.UInt16: throw new NotSupportedException(dbType.ToString());
         case DbType.UInt32: throw new NotSupportedException(dbType.ToString());
         case DbType.UInt64: throw new NotSupportedException(dbType.ToString());
         case DbType.VarNumeric: throw new NotSupportedException(dbType.ToString());
         case DbType.AnsiStringFixedLength: return SqlDbType.Char;
         case DbType.StringFixedLength: return SqlDbType.NChar;
         default: throw new NotSupportedException(dbType.ToString());
     }
 }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:33,代码来源:SqlConvert.cs

示例4: CreateColumn

        public void CreateColumn(string tableName, string columnName, DbType dbType)
        {
            ILoggingService loggingService = engine.GetService<ILoggingService>();
            if (loggingService != null)
                loggingService.LogInfo(this, String.Format("Creating {0} column {1} in table {2} in NPersist mapping file.",
                    dbType.ToString(), columnName, tableName));

            ITableMap tableMap = GetDomainMap().GetSourceMap().MustGetTableMap(tableName);

            //Add the column to the npersist xml file
            IColumnMap columnMap = new ColumnMap(columnName);
            columnMap.TableMap = tableMap;
            columnMap.DataType = dbType;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:14,代码来源:NPersistSchemaService.cs

示例5: DeclareParamater

 public int DeclareParamater(DbCommand command, string name, DbType type)
 {
     if (!command.Parameters.Contains(name)) {
         string dbType = type.ToString();
         if(type == DbType.DateTime) {
             return command.Parameters.Add(new MySqlParameter(name, MySqlDbType.DateTime));
         }
         else if(type == DbType.Double) {
             return command.Parameters.Add(new MySqlParameter(name, MySqlDbType.Double));
         }
         else {
             return command.Parameters.Add(new MySqlParameter(name, dbType));
         }
     } else {
         throw new ArgumentException(string.Format("Parameter {0} already exists", name));
     }
 }
开发者ID:Ethon,项目名称:mcflurry_simulator,代码行数:17,代码来源:MYSQLDatabase.cs

示例6: Convert

		public static string Convert(DbType t) {
			switch (t) {
				case DbType.UNKNOWN:
					return "UNKNOWN";
				case DbType.ACCESS:
					return "ACCESS";
				case DbType.DB2:
					return "DB2";
				case DbType.MYSQL:
					return "MYSQL";
				case DbType.ORACLE:
					return "ORACLE";
				case DbType.SQLSERVER:
					return "SQLSERVER";
				default:
					throw new Exception("DbType " + t.ToString() + " not found.");
			}
		}
开发者ID:BackupTheBerlios,项目名称:ch3etah-svn,代码行数:18,代码来源:DbTypeConverter.cs

示例7: DbTypeNotSupported

 internal static ArgumentException DbTypeNotSupported(DbType type, Type enumtype)
 {
     return Argument(System.Data.Res.GetString("ADP_DbTypeNotSupported", new object[] { type.ToString(), enumtype.Name }));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:ADP.cs

示例8: ColumnAttribute

 /// <summary>
 /// 初始化一个新的列标记。
 /// </summary>
 /// <param name="name">列名称。</param>
 /// <param name="dbType">数据类型。</param>
 public ColumnAttribute(string name, DbType dbType)
 {
     if (string.IsNullOrWhiteSpace(name))
         throw new ArgumentNullException("name");
     Name = name;
     _typeName = dbType.ToString();
 }
开发者ID:l1183479157,项目名称:RabbitHub,代码行数:12,代码来源:ColumnAttribute.cs

示例9: DBType2DBEmptyValue

			// <summary>
			// Aimed for code generator, hence returning straight string.
			// </summary>
			public static string DBType2DBEmptyValue(DbType dbType_in, eDBServerTypes dbServerType_in) {
				switch (dbType_in) {
					case DbType.DateTime:
					case DbType.Date:
					case DbType.Time: {
						return object2SQLobject(
							new DateTime(1900, 1, 1), 
							dbServerType_in
						);
					}
					case DbType.Int16: 
					case DbType.Int32: 
					case DbType.Int64:
					case DbType.UInt16: 
					case DbType.UInt32: 
					case DbType.UInt64:
					case DbType.Byte: 
					case DbType.Single: 
					case DbType.Double: 
					case DbType.Decimal:
					case DbType.Boolean: {
						return "0";
					}
					case DbType.String: {
						return "''";
					}
					case DbType.Binary: {
						return "new Byte[] {}";
					}

					// ToDos: here!
				}
				throw new Exception(string.Format(
					"undefined variable type: {0}",
					dbType_in.ToString() // dbType_in.GetType().ToString()
				));
			}
开发者ID:katshann,项目名称:ogen,代码行数:40,代码来源:utils.cs

示例10: GetDbTypeString

        protected override string GetDbTypeString(DbType type, int precision)
        {
            switch (type) {
                case DbType.String:
                    if (precision > 0) {
                        return "VARCHAR(" + precision + ")";
                    }
                    return "VARCHAR(255)";
                case DbType.Binary: return "BINARY";
                case DbType.Double: return "DOUBLE";
                case DbType.Boolean: return "BOOLEAN";
                case DbType.Decimal: return "DECIMAL";
                case DbType.Guid: return "VARCHAR(40)";
                case DbType.Int16: return "SMALLINT";
                case DbType.Int32: return "INT";
                case DbType.Single: return "INT";
                case DbType.Int64: return "BIGINT";
                case DbType.Date: return "DATETIME";
            }

            throw new DataTypeNotAvailableException(String.Format("The type {0} is no available for mysql", type.ToString()));
        }
开发者ID:heitorbelloni,项目名称:sharpmigrations,代码行数:22,代码来源:MySqlDialect.cs

示例11: InvalidFormatErrorMessage

 private string InvalidFormatErrorMessage(DbType expected, int fieldNumber, string value)
 {
     return string.Format("Error reading line: {0}, field: {1}. Expected a DbType.{2}, got: '{3}'",
          LineNumber,
          fieldNumber,
          expected.ToString(),
         value
         );
 }
开发者ID:GrowingData,项目名称:Mung,代码行数:9,代码来源:MungedDataReader.cs

示例12: DbTypeToString

        public string DbTypeToString(DbType type, int size, int precision)
        {
            switch (type)
            {
                case DbType.Guid:
                    return "char(38)";

                case DbType.AnsiString:
                case DbType.String:
                    if (size <= 8192) return string.Format("VARCHAR({0})", size);
                    else if (8192 < size && size <= UInt16.MaxValue) return "TEXT";
                    else if (UInt16.MaxValue < size && size <= ((int)Math.Pow(2, 24) - 1)) return "MEDIUMTEXT";
                    else return "LONGTEXT";

                case DbType.AnsiStringFixedLength:
                case DbType.StringFixedLength:
                    return string.Format("CHAR({0})", size);

                case DbType.Xml:
                    return "MEDIUMTEXT";

                case DbType.Binary:
                case DbType.Object:
                    if (size <= 8192) return string.Format("BINARY({0})", size);
                    else if (8192 < size && size <= UInt16.MaxValue) return "BLOB";
                    else if (UInt16.MaxValue < size && size <= ((int)Math.Pow(2, 24) - 1)) return "MEDIUMBLOB";
                    else return "LONGBLOB";

                case DbType.Boolean:
                case DbType.Byte:
                    return "TINYINY";
                case DbType.SByte:
                    return "TINYINY UNSIGNED";

                case DbType.Int16:
                    return "SMALLINT";
                case DbType.UInt16:
                    return "SMALLINT UNSIGNED";

                case DbType.Int32:
                    return "INT";
                case DbType.UInt32:
                    return "INT UNSIGNED";

                case DbType.Int64:
                    return "BIGINT";
                case DbType.UInt64:
                    return "BIGINT UNSIGNED";

                case DbType.Date:
                    return "DATE";
                case DbType.DateTime:
                case DbType.DateTime2:
                    return "DATETIME";
                case DbType.Time:
                    return "TIME";

                case DbType.Decimal:
                    return string.Format("DECIMAL({0},{1})", size, precision);
                case DbType.Double:
                    return "DOUBLE";
                case DbType.Single:
                    return "FLOAT";

                default:
                    throw new ArgumentOutOfRangeException(type.ToString());
            }
        }
开发者ID:vlslavik,项目名称:teamlab.v7.5,代码行数:68,代码来源:MySQLDialect.cs

示例13: ConvertDbTypeToString

        public virtual string ConvertDbTypeToString(DbType dbtype, int size, byte precision, byte scale)
        {
            SqlType sqlType = TypeName(dbtype, size);

            if (sqlType == null)
                throw new SqlMapperException(String.Format("Mapping data type unknown [{0}]", dbtype.ToString()));

            switch (dbtype)
            {
                case DbType.AnsiString:
                case DbType.AnsiStringFixedLength:
                    return sqlType.FormatType(MaxAnsiStringSize, size, precision, scale);
                case DbType.String:
                case DbType.StringFixedLength:
                    return sqlType.FormatType(MaxStringSize, size, precision, scale);
                case DbType.Binary:
                    return sqlType.FormatType(MaxBinarySize, size, precision, scale);
                default:
                    return sqlType.FormatType(size == 0 ? sqlType.Size : size, precision == 0 ? sqlType.Precision : precision, scale == 0 ? sqlType.Scale : scale);
            }
        }
开发者ID:npenin,项目名称:uss,代码行数:21,代码来源:DBDialect.cs

示例14: GetDbFilePath

 /// <summary>
 /// Builds the expected database file path
 /// </summary>
 /// <param name="db">The type of database file</param>
 /// <param name="pos">The part of speech</param>
 /// <returns>The expected database file path</returns>
 private string GetDbFilePath( DbType db, WordNetAccess.PartOfSpeech pos )
 {
     string lcdb = db.ToString().ToLower();
     string lcpos = pos.ToString().ToLower();
     return Path.Combine( dictdir, string.Format( "{0}.{1}", lcdb, lcpos ) );
 }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:12,代码来源:FileWordNetTools.cs

示例15: GetParameterType

        /// <summary>
        /// ��ȡ���ݿ������ֶ�����
        /// </summary>
        /// <param name="provider">�����ṩ��</param>
        /// <param name="dbType">������������</param>
        /// <returns>CommonConst.ReturnValue</returns>
        public static short GetParameterType(DataProvider provider, DbType dbType)
        {
            if (provider == DataProvider.SqlClient)
            {
                if (dbType == DbType.String)
                    return (short)System.Data.SqlDbType.Text;
                else if (dbType == DbType.Binary)
                    return (short)System.Data.SqlDbType.Image;
                else if (dbType == DbType.DateTime)
                    return (short)System.Data.SqlDbType.DateTime;
                else if (dbType == DbType.Int32)
                    return (short)System.Data.SqlDbType.Int;
                else if (dbType == DbType.Single)
                    return (short)System.Data.SqlDbType.Float;
            }
            else if (provider == DataProvider.ODPNET)
            {
                if (dbType == DbType.String)
                    return (short)Oracle.DataAccess.Client.OracleDbType.Varchar2;
                else if (dbType == DbType.Binary)
                    return (short)Oracle.DataAccess.Client.OracleDbType.Blob;
                else if (dbType == DbType.DateTime)
                    return (short)Oracle.DataAccess.Client.OracleDbType.TimeStamp;
                else if (dbType == DbType.Int32)
                    return (short)Oracle.DataAccess.Client.OracleDbType.Int32;
                else if (dbType == DbType.Single)
                    return (short)Oracle.DataAccess.Client.OracleDbType.Single;
            }
            else if (provider == DataProvider.MySqlClient)
            {
                if (dbType == DbType.String)
                    return (short)MySql.Data.MySqlClient.MySqlDbType.VarString;
                else if (dbType == DbType.Binary)
                    return (short)MySql.Data.MySqlClient.MySqlDbType.LongBlob;
                else if (dbType == DbType.DateTime)
                    return (short)MySql.Data.MySqlClient.MySqlDbType.Time;
                else if (dbType == DbType.Int32)
                    return (short)MySql.Data.MySqlClient.MySqlDbType.Int32;
                else if (dbType == DbType.Single)
                    return (short)MySql.Data.MySqlClient.MySqlDbType.Float;
            }
            else if (provider == DataProvider.OracleClient)
            {
                if (dbType == DbType.String)
                    return (short)System.Data.OracleClient.OracleType.LongVarChar;
                else if (dbType == DbType.Binary)
                    return (short)System.Data.OracleClient.OracleType.Blob;
                else if (dbType == DbType.DateTime)
                    return (short)System.Data.OracleClient.OracleType.DateTime;
                else if (dbType == DbType.Int32)
                    return (short)System.Data.OracleClient.OracleType.Int32;
                else if (dbType == DbType.Single)
                    return (short)System.Data.OracleClient.OracleType.Float;
            }

            else if (provider == DataProvider.Odbc)
            {
                if (dbType == DbType.String)
                    return (short)System.Data.Odbc.OdbcType.Text;
                else if (dbType == DbType.Binary)
                    return (short)System.Data.Odbc.OdbcType.Image;
                else if (dbType == DbType.DateTime)
                    return (short)System.Data.Odbc.OdbcType.DateTime;
                else if (dbType == DbType.Int32)
                    return (short)System.Data.Odbc.OdbcType.Int;
                else if (dbType == DbType.Single)
                    return (short)System.Data.Odbc.OdbcType.Real;
            }
            else
            {
                if (dbType == DbType.String)
                    return (short)System.Data.OleDb.OleDbType.LongVarChar;
                else if (dbType == DbType.Binary)
                    return (short)System.Data.OleDb.OleDbType.LongVarBinary;
                else if (dbType == DbType.DateTime)
                    return (short)System.Data.OleDb.OleDbType.DBTimeStamp;
                else if (dbType == DbType.Int32)
                    return (short)System.Data.OleDb.OleDbType.Integer;
                else if (dbType == DbType.Single)
                    return (short)System.Data.OleDb.OleDbType.Single;
            }
            throw new Exception(string.Format("�Ƿ�����������:{0}", dbType.ToString()));
        }
开发者ID:zuifengke,项目名称:windy-common,代码行数:89,代码来源:ProviderFactory.cs


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