(转)C# 数据类型映射 (SQLite,MySQL,MSSQL,Oracle)
一、C# vs SQLite:
C# | SQLite | ||||
字段名 | 类型 | 库类型 | GetFieldType(#) | 转换 | 备注 |
F_BOOL | bool | BIT NOT NULL | Boolean | ||
F_BOOL_NULL | bool? | BIT | Boolean | ||
F_SBYTE | sbyte | INT8 NOT NULL | SByte | sbyte_ | |
F_SBYTE_NULL | sbyte? | INT8 | SByte | sbyte_ | |
F_BYTE | byte | UINT8 NOT NULL | Byte | ||
F_BYTE_NULL | byte? | UINT8 | Byte | ||
F_SHORT | short | INT16 NOT NULL | Int16 | ||
F_SHORT_NULL | short? | INT16 | Int16 | ||
F_USHORT | ushort | UINT16 NOT NULL | UInt16 | ushort_ | |
F_USHORT_NULL | ushort? | UINT16 | UInt16 | ushort_ | |
F_INT | int | INT32 NOT NULL | Int32 | ||
F_INT_NULL | int? | INT32 | Int32 | ||
F_UINT | uint | UINT32 NOT NULL | UInt32 | uint_ | |
F_UINT_NULL | uint? | UINT32 | UInt32 | uint_ | |
F_LONG | long | INT64 NOT NULL | Int64 | ||
F_LONG_NULL | long? | INT64 | Int64 | ||
F_ULONG | ulong | UINT64 NOT NULL | UInt64 | ulong_ | |
F_ULONG_NULL | ulong? | UINT64 | UInt64 | ulong_ | |
F_FLOAT | float | FLOAT NOT NULL | Double | 不转兼容 | |
F_FLOAT_NULL | float? | FLOAT | Double | 不转兼容 | |
F_DOUBLE | double | DOUBLE NOT NULL | Double | ||
F_DOUBLE_NULL | double? | DOUBLE | Double | ||
F_DECIMAL | decimal | DECIMAL NOT NULL | Decimal | 存取不一:<F_DECIMAL>: [-79228162514264300000000000000] != [-79228162514264337593543950335] | |
F_DECIMAL_NULL | decimal? | DECIMAL | Decimal | 存取不一:<F_DECIMAL>: [-79228162514264300000000000000] != [-79228162514264337593543950335] | |
F_CHAR | char | TEXT NOT NULL | String | ||
F_CHAR_NULL | char? | TEXT | String | ||
F_STRING | string | TEXT NOT NULL | String | ||
F_STRING_NULL | string | TEXT | String | ||
F_DATETIME | DateTime | TEXT NOT NULL | String | ||
F_DATETIME_NULL | DateTime? | TEXT | String | ||
二、 C# vs MySQL:
C# | MySQL | ||||
字段名 | 类型 | 库类型 | GetFieldType(#) | 转换 | 备注 |
F_BOOL | bool | BOOL NOT NULL | Boolean | ||
F_BOOL_NULL | bool? | BOOL NULL | Boolean | ||
F_SBYTE | sbyte | TINYINT NOT NULL | SByte | sbyte_ | |
F_SBYTE_NULL | sbyte? | TINYINT NULL | SByte | sbyte_ | |
F_BYTE | byte | TINYINT UNSIGNED NOT NULL | Byte | ||
F_BYTE_NULL | byte? | TINYINT UNSIGNED NULL | Byte | ||
F_SHORT | short | SMALLINT NOT NULL | Int16 | ||
F_SHORT_NULL | short? | SMALLINT NULL | Int16 | ||
F_USHORT | ushort | SMALLINT UNSIGNED NOT NULL | UInt16 | ushort_ | |
F_USHORT_NULL | ushort? | SMALLINT UNSIGNED NULL | UInt16 | ushort_ | |
F_INT | int | INT NOT NULL | Int32 | ||
F_INT_NULL | int? | INT NULL | Int32 | ||
F_UINT | uint | INT UNSIGNED NOT NULL | UInt32 | uint_ | |
F_UINT_NULL | uint? | INT UNSIGNED NULL | UInt32 | uint_ | |
F_LONG | long | BIGINT NOT NULL | Int64 | ||
F_LONG_NULL | long? | BIGINT NULL | Int64 | ||
F_ULONG | ulong | BIGINT UNSIGNED NOT NULL | UInt64 | ulong_ | |
F_ULONG_NULL | ulong? | BIGINT UNSIGNED NULL | UInt64 | ulong_ | |
F_FLOAT | float | FLOAT NOT NULL | Single | 极值溢出 | |
F_FLOAT_NULL | float? | FLOAT NULL | Single | 极值溢出 | |
F_DOUBLE | double | DOUBLE NOT NULL | Double | ||
F_DOUBLE_NULL | double? | DOUBLE NULL | Double | ||
F_DECIMAL | decimal | DECIMAL NOT NULL | Decimal | 极值溢出 | |
F_DECIMAL_NULL | decimal? | DECIMAL NULL | Decimal | 极值溢出 | |
F_CHAR | char | CHARACTER NOT NULL | String | 中文报错 | |
F_CHAR_NULL | char? | CHARACTER NULL | String | 中文报错 | |
F_STRING | string | VARCHAR(50) NOT NULL | String | ||
F_STRING_NULL | string | VARCHAR(50) NULL | String | ||
F_DATETIME | DateTime | DATETIME NOT NULL | DateTime | ||
F_DATETIME_NULL | DateTime? | DATETIME NULL | DateTime | ||
三、 C# vs MSSQL:
C# | MSSQL | ||||
字段名 | 类型 | 库类型 | GetFieldType(#) | 转换 | 备注 |
F_BOOL | bool | bit NOT NULL | Boolean | ||
F_BOOL_NULL | bool? | bit NULL | Boolean | ||
F_SBYTE | sbyte | smallint NOT NULL | Int16 | sbyte_short | |
F_SBYTE_NULL | sbyte? | smallint NULL | Int16 | sbyte_short | |
F_BYTE | byte | tinyint NOT NUL; | Byte | ||
F_BYTE_NULL | byte? | tinyint NULL | Byte | ||
F_SHORT | short | smallint NOT NULL | Int16 | ||
F_SHORT_NULL | short? | smallint NULL | Int16 | ||
F_USHORT | ushort | int NOT NULL | Int32 | ushort_int | |
F_USHORT_NULL | ushort? | int NULL | Int32 | ushort_int | |
F_INT | int | int NOT NULL | Int32 | ||
F_INT_NULL | int? | int NULL | Int32 | ||
F_UINT | uint | bigint NOT NULL | Int64 | uint_long | |
F_UINT_NULL | uint? | bigint NULL | Int64 | uint_long | |
F_LONG | long | bigint NOT NULL | Int64 | ||
F_LONG_NULL | long? | bigint NULL | Int64 | ||
F_ULONG | ulong | real NOT NULL | Single | ulong_float | |
F_ULONG_NULL | ulong? | real NULL | Single | ulong_float | |
F_FLOAT | float | real NOT NULL | Single | ||
F_FLOAT_NULL | float? | real NULL | Single | ||
F_DOUBLE | double | float NOT NULL | Double | ||
F_DOUBLE_NULL | double? | float NULL | Double | ||
F_DECIMAL | decimal | decimal NOT NULL | Decimal | 极值溢出 | |
F_DECIMAL_NULL | decimal? | decimal NULL | Decimal | 极值溢出 | |
F_CHAR | char | char(1) NOT NULL | String | ||
F_CHAR_NULL | char? | char(1) NULL | String | ||
F_STRING | string | varchar(50) NOT NULL | F_STRING: | ||
F_STRING_NULL | string | varchar(50) NULL | String | ||
F_DATETIME | DateTime | datetime NOT NULL | DateTime | 必须介于 1/1/1753 12:00:00 AM 和 12/31/9999 11:59:59 PM 之间。 | |
F_DATETIME_NULL | DateTime? | datetime NULL | DateTime | ||
四、C# vs Oracle:
C# | Oracle | ||||
字段名 | 类型 | 库类型 | GetFieldType(#) | 转换 | 备注 |
F_BOOL | bool | CHAR(1) NOT NULL | String | bool_string | |
F_BOOL_NULL | bool? | CHAR(1) | String | bool_string | |
F_SBYTE | sbyte | NUMBER(3) NOT NULL | Int16 | sbyte_short | |
F_SBYTE_NULL | sbyte? | NUMBER(3) | Int16 | sbyte_short | |
F_BYTE | byte | NUMBER(3) NOT NULL | Int16 | byte_short | |
F_BYTE_NULL | byte? | NUMBER(3) | Int16 | byte_short | |
F_SHORT | short | NUMBER(5) NOT NULL | Int32 | short_int | |
F_SHORT_NULL | short? | NUMBER(5) | Int32 | short_int | |
F_USHORT | ushort | NUMBER(5) NOT NULL | Int32 | ushort_int | |
F_USHORT_NULL | ushort? | NUMBER(5) | Int32 | ushort_int | |
F_INT | int | NUMBER(10) NOT NULL | Int64 | int_long | |
F_INT_NULL | int? | NUMBER(10) | Int64 | int_long | |
F_UINT | uint | NUMBER(10) NOT NULL | Int64 | uint_long | |
F_UINT_NULL | uint? | NUMBER(10) | Int64 | uint_long | |
F_LONG | long | NUMBER(19) NOT NULL | Decimal | long_decimal | |
F_LONG_NULL | long? | NUMBER(19) | Decimal | long_decimal | |
F_ULONG | ulong | NUMBER(19) NOT NULL | Decimal | ulong_decimal | |
F_ULONG_NULL | ulong? | NUMBER(19) | Decimal | ulong_decimal | |
F_FLOAT | float | BINARY_FLOAT NOT NULL | Single | ||
F_FLOAT_NULL | float? | BINARY_FLOAT | Single | ||
F_DOUBLE | double | BINARY_DOUBLE NOT NULL | Double | 极值溢出 | |
F_DOUBLE_NULL | double? | BINARY_DOUBLE | Double | 极值溢出 | |
F_DECIMAL | decimal | DECIMAL(33,3) NOT NULL | Decimal | ||
F_DECIMAL_NULL | decimal? | DECIMAL(33,3) | Decimal | ||
F_CHAR | char | CHAR(1) NOT NULL | String | ||
F_CHAR_NULL | char? | CHAR(1) | String | ||
F_STRING | string | VARCHAR(50) NOT NULL | String | 不允许空字符 | |
F_STRING_NULL | string | VARCHAR(50) | String | 不允许空字符 | |
F_DATETIME | DateTime | TIMESTAMP NOT NULL | DateTime | 大值读取报错 | |
F_DATETIME_NULL | DateTime? | TIMESTAMP | DateTime | 大值读取报 |
using System;
using System.Collections.Generic;
using System.Text; namespace vJine.Core.ORM {
public class TypeConverter { public class sbyte_ /*: IConverter<sbyte>*/ {
public static sbyte CONV_Q(object V) {
return (sbyte)V;
}
} public class ushort_ /*: IConverter<ushort>*/ {
public static ushort CONV_Q(object V) {
return (ushort)V;
}
} public class uint_ /*: IConverter<uint>*/ {
public static uint CONV_Q(object V) {
return (uint)V;
}
} public class ulong_ /*: IConverter<ulong>*/ {
public static ulong CONV_Q(object V) {
return (ulong)V;
}
} public class bool_string /*: IConverter<bool>*/ {
public static object CONV_I(object V) {
if ((bool)V == true) {
return "";
} else {
return "";
}
} public static bool CONV_Q(object V) {
if ((string)V == "") {
return true;
} else {
return false;
}
}
} public class sbyte_short /*: IConverter<sbyte>*/ { public static object CONV_I(object V) {
return Convert.ToInt16(V);
} public static sbyte CONV_Q(object V) {
return Convert.ToSByte(V);
}
} public class byte_short /*: IConverter<byte>*/ {
public static object CONV_I(object V) {
return Convert.ToInt16(V);
} public static byte CONV_Q(object V) {
return Convert.ToByte(V);
}
} public class short_int /*: IConverter<short>*/ {
public static object CONV_I(object V) {
return Convert.ToInt32(V);
} public static short CONV_Q(object V) {
return Convert.ToInt16(V);
}
} public class ushort_int /*: IConverter<ushort>*/ {
public static object CONV_I(object V, string Name) {
return Convert.ToInt32(V);
} public static ushort CONV_Q(object V, string Name) {
return Convert.ToUInt16(V);
}
} public class int_long /*: IConverter<int>*/ {
public static object CONV_I(object V) {
return Convert.ToInt64(V);
} public static int CONV_Q(object V) {
return Convert.ToInt32(V);
}
} public class uint_long /*: IConverter<uint>*/ {
public static object CONV_I(object V) {
return Convert.ToInt64(V);
} public static uint CONV_Q(object V) {
return Convert.ToUInt32(V);
}
} public class long_decimal /*: IConverter<long>*/ {
public static object CONV_I(object V) {
return decimal.Parse(V.ToString());
} public static long CONV_Q(object V) {
return long.Parse(V.ToString());
}
} public class ulong_float /*: IConverter<ulong>*/ {
public static object CONV_I(object V) {
return Convert.ToSingle(V);
} public static ulong CONV_Q(object V) {
return Convert.ToUInt64(V);
}
} public class ulong_decimal /*: IConverter<ulong>*/ {
public static object CONV_I(object V) {
return decimal.Parse(V.ToString());
} public static ulong CONV_Q(object V) {
return ulong.Parse(V.ToString());
}
} public class float_double /*: IConverter<float>*/ {
public static object CONV_I(object V) {
return Convert.ToDouble(V);
} public static float CONV_Q(object V) {
return Convert.ToSingle(V);
}
} public class char_string /*: IConverter<char>*/ {
public static object CONV_I(object V) {
if (V is Char) {
return V;
} else if (V is string) {
string chars = (string)V;
if (chars == "") {
return '\0';
} else {
return chars[];
}
} else {
throw new OrmException("Fail To Convert String[{0}] To Char", V);
}
} public static char CONV_Q(object V) {
return ((string)V)[];
}
} public class DateTime_ /*: IConverter<DateTime>*/ {
public static object CONV_I(object V) {
return V;
} public static DateTime CONV_Q(object V) {
return (DateTime)V;
}
}
}
}
(转)C# 数据类型映射 (SQLite,MySQL,MSSQL,Oracle)的更多相关文章
- C# 数据类型映射 (SQLite,MySQL,MSSQL,Oracle)
一.C# vs SQLite: C# SQLite 字段名 类型 库类型 GetFieldType(#) 转换 备注 F_BOOL bool BIT NOT NULL Boolean F_BOOL_N ...
- Hibernate常用的Java数据类型映射到mysql和Oracle
研究了常用的Java基本数据类型在mysql和oracle数据库的映射类型.这里使用的是包装类型做研究,一般在hibernate声明的时候最好不要用基本类型,因为数据库中的null空数据有可能映射为基 ...
- Oracle 数据类型映射C#
Oracle 数据类型映射 下表列出 Oracle 数据类型及其与 OracleDataReader 的映射. Oracle 数据类型 由 OracleDataReader.GetValue 返回的 ...
- MySql - JdbcType - Oracle类型映射
MySql - JdbcType - Oracle类型映射 MySQL数据类型 JDBC TYPE Oracle数据类型 BIGINT BIGINT NUMBER(20) TINYINT TINY ...
- Mysql,Oracle与Java字段类型映射关系
Mysql,Oracle与Java字段类型映射关系 参考相关博文 MySQL/Oracle字段类型 Java字段类型 最大长度 BIT java.lang.Boolean 1 BLOB java.la ...
- 《物联网框架ServerSuperIO教程》-19.设备驱动和OPC Client支持mysql、oracle、sqlite、sqlserver的持久化。v3.6.4版本发布
19.设备驱动和OPC Client支持mysql.oracle.sqlite.sqlserver的持久化 19.1 概述 ServerSuperIO支持设备驱动和OPC Client采集的数 ...
- mysql 和 Oracle 数据类型对照
MySQL与Oracle两种数据库在工作中,都是用的比较多的数据库,由于MySQL与Oracle在数据类型上有部分差异,在我们迁移数据库时,会遇上一定的麻烦,下面介绍MySQL与Oracle数据库数据 ...
- sequelize 用于PostgreSQL,MySQL,SQLite和MSSQL的Node.js / io.js ORM
安装 Sequelize可通过NPM获得. $ npm install --save sequelize # And one of the following: $ npm install --sav ...
- springboot+mybatis+druid+sqlite/mysql/oracle
搭建springboot+mybatis+druid+sqlite/mysql/oracle附带测试 1.版本 springboot2.1.6 jdk1.8 2.最简springboot环境 http ...
随机推荐
- OA系统权限管理设计(转载)
不论什么系统都离不开权限的管理,有一个好的权限管理模块,不仅使我们的系统操作自如,管理方便,也为系统加入亮点. l 不同职责的人员,对于系统操作的权限应该是不同的.优秀的业务系统,这是 ...
- delphi queryCommandState
如何 获取当前光标所在的字符属性 关键点 function queryCommandState(const cmdID: WideString): WordBool; safecall; 粗体 斜体 ...
- 调用Dll里面的窗体
将窗体资源分装到DLL中并且调用 用Delphi生成DLL并封装窗体的示例 调用Dll里面的窗体 DLL文件 library Project2;{ Important note about DLL m ...
- Android Socket编程学习笔记
http://blog.csdn.net/eyu8874521/article/details/8847173 度娘给出的描述:通常也称作"套接字",用于描述IP地址和端口,是一个 ...
- PhoneTutorial
https://github.com/navasmdc/PhoneTutorial PhoneTutorial-master.zip
- 将Uploads文件夹移到其它地方
1.在创建目录 cd /mnt/xvdb mkdir qingtong 2.复制目录和权限 cp -rp /Uploads/ ./ -r 包括目录 p权限 3.创建软链接 ln -s /mnt/xvd ...
- mysql 5.6 binlog组提交
mysql 5.6 binlog组提交实现原理 http://blog.itpub.net/15480802/viewspace-1411356 Redo组提交 Redo提交流程大致如下 lock l ...
- [ZZ]C++中,引用和指针的区别
(1) 引用总是指向一个对象,没有所谓的 null reference .所有当有可能指向一个对象也由可能不指向对象则必须使用 指针. 由于C++ 要求 reference 总是指向一个对象所以 re ...
- 分布式文件系统之GPFS
GPFS是IBM公司通过完善和发展其Tiger Shark文件系统发展而来.GPFS通过共享磁盘结构来实现其强大的扩展性.一个GPFS系统由许多集群节点组成,GPFS文件系统和应用程序在上面运行.这些 ...
- Android广播接收者应用(电话拦截器)
一.电话拦截器应用说明 在我们输入完电话号码并拨打电话时,系统会发出一个有序广播(action="android.intent.action.NEW_OUTGOING_CALL") ...