Kdbndp支持的类型和类型映射
==========================

下面列出了将CLR类型读取和写入KingbaseES类型时的内置映射。

- 读取映射_
- 写映射_

读取映射
--------

下面显示了读取值时使用的映射

-  使用和类似方式：KdbndpCommand.ExecuteScalar()，将返回默认类型KdbndpDataReader.GetValue()；

-  可以通过调用读取为其它类型：KdbndpDataReader.GetFieldValue()；

-  提供程序特定的类型并返回：KdbndpDataReader.GetProviderSpecificvalValue()。


.. table:: MySQL模式读取数据时 KingbaseES 数据类型和.NET 类型之间映射
   :class: longtable

   +--------------------+----------------+------------------+-------------------------------------------+
   | KingbaseES数据类型 | 默认.NET类型   | KdbndpDbType类型 | 其它.NET类型                              |
   +====================+================+==================+===========================================+
   | boolean            | boolean        | Boolean          |                                           |
   +--------------------+----------------+------------------+-------------------------------------------+
   | smallint           | short          | Smallint         | byte,sbyte,int,long,float,double,decimal  |
   +--------------------+----------------+------------------+-------------------------------------------+
   | bigint             | long           | Bigint           | byte,short,long,float,double,decimal      |
   +--------------------+----------------+------------------+-------------------------------------------+
   | int                | int            | Integer          | byte,short,long,float,double,decimal      |
   +--------------------+----------------+------------------+-------------------------------------------+
   | uint4              | uint           | Uint4            | byte,short,long,float,double,decimal      |
   +--------------------+----------------+------------------+-------------------------------------------+
   | uint8              | ulong          | uint8            | byte,short,long,float,double,decimal      |
   +--------------------+----------------+------------------+-------------------------------------------+
   | tinyint            | sbyte          | Tinyint          | bool,byte,short,long,float,double,decimal |
   +--------------------+----------------+------------------+-------------------------------------------+
   | mediumint          | int            | Mediumint        | byte,short,long,float,double,decimal      |
   +--------------------+----------------+------------------+-------------------------------------------+
   | float4             | float          | Real             | double                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | double             | precision      | double           |                                           |
   +--------------------+----------------+------------------+-------------------------------------------+
   | numeric            | decimal        | Numeric          | byte,short,int,long,float,double          |
   +--------------------+----------------+------------------+-------------------------------------------+
   | money              | decimal        | Money            |                                           |
   +--------------------+----------------+------------------+-------------------------------------------+
   | text               | string         | Text             | char[]                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | tinytext           | string         | tinytext         | char[]                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | mediumtext         | string         | Mediumtext       | char[]                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | longtext           | string         | Longtext         | char[]                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | char(36)           | Guid           | Uuid             |                                           |
   +--------------------+----------------+------------------+-------------------------------------------+
   | timestamp          | DateTimeOffset | Mysql_Timestamp  |                                           |
   +--------------------+----------------+------------------+-------------------------------------------+
   | date               | Date           | Mysql_Date       |                                           |
   +--------------------+----------------+------------------+-------------------------------------------+
   | time               | Time           | Mysql_Time       |                                           |
   +--------------------+----------------+------------------+-------------------------------------------+
   | year               | short          | Year             |                                           |
   +--------------------+----------------+------------------+-------------------------------------------+
   | datetime           | DateTime       | Mysql_DateTime   |                                           |
   +--------------------+----------------+------------------+-------------------------------------------+
   | bit                | BitArray       | Mysql_bit        | binary,bool,string                        |
   +--------------------+----------------+------------------+-------------------------------------------+
   | bianry             | Byte[]         | Binary           | binary                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | varbinary          | Byte[]         | VarBinary        | binary                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | tinyblob           | Byte[]         | Tinyblob         | binary                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | blob               | Byte[]         | Blob             | binary                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | mediumblob         | Byte[]         | Mediumblob       | binary                                    |
   +--------------------+----------------+------------------+-------------------------------------------+
   | longblob           | Byte[]         | longblob         | binary                                    |
   +--------------------+----------------+------------------+-------------------------------------------+


写映射
------

有以下三个规则确定为参数发送KingbaseES类型：

-  如果参数设置了KdbndpDbType,则使用它；

-  如果参数设置了DataType,则使用它；

-  如果参数设置了DbType，则使用它；

-  如果未设置上述任何一项，则将从CLR值类型推断后端类型。


.. table:: MySQL模式写数据时KingbaseES 数据类型和 .NET类型之间映射
   :widths: 2 2 2 3   
   :class: longtable
      
   +-----------------+-----------+-----------------+-------------------------------------------+
   | KdbndpDbType    | DbType    | KingbaseES 类型 | 可接受的.NET 类型                         |
   +=================+===========+=================+===========================================+
   | Boolean         | bool      | boolean         |                                           |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Smallint        | short     | smallint        | byte,sbyte,int,long,float,double,decimal  |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Bigint          | long      | bigint          | byte,short,long,float,double,decimal      |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Integer         | int       | int             | byte,short,long,float,double,decimal      |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Uint4           | uint      | uint4           | byte,short,long,float,double,decimal      |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Uint8           | ulong     | uint8           | byte,short,long,float,double,decimal      |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Tinyint         | sbyte     | tinyint         | bool,byte,short,long,float,double,decimal |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Mediumint       | int       | mediumint       | byte,short,long,float,double,decimal      |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Real            | float     | float4          | double                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | double          | precision | double          |                                           |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Numeric         | decimal   | numeric         | byte,short,int,long,float,double          |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Money           | decimal   | money           |                                           |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Text            | string    | text            | char[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Tinytext        | string    | tinytext        | char[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Mediumtext      | string    | mediumtext      | char[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Longtext        | string    | longtext        | char[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Uuid            | Guid      | char(36)        |                                           |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Mysql_Timestamp | DateTime  | timestamp       |                                           |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Mysql_Date      | Date      | date            |                                           |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Mysql_Time      | Time      | time            |                                           |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Year            | short     | year            |                                           |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Mysql_DateTime  | DateTime  | datetime        |                                           |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Mysql_bit       | BitArray  | bit             | bool,string                               |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Binary          | Binary    | bianry          | Byte[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | VarBinary       | Binary    | varbinary       | Byte[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Tinyblob        | Binary    | tinyblob        | Byte[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Blob            | Binary    | blob            | Byte[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Mediumblob      | Binary    | mediumblob      | Byte[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
   | Longblob        | Binary    | longblob        | Byte[]                                    |
   +-----------------+-----------+-----------------+-------------------------------------------+
