mysql中的tinyint在c#中显示为布尔值

sjd*_*sjd 1 c# mysql ado.net tinyint

我的查询tinyint(1)从 mysql 中的表中获取字段,如下所示

mysqlcommand.selectquery="select vehicletype from vehicles where id=1"
Run Code Online (Sandbox Code Playgroud)

可能的值为vehicletype1 到 7

但该datatable字段行中的输出显示为boolean

datatable dtresult;
mda.Fill(dtResult);
DataRow dr = dtResult.Rows[0];
//dr["vehicletype "]=false if 0
//dr["vehicletype "]=true if 1
//dr["vehicletype "]=true if 2
//dr["vehicletype "]=true if 3
//dr["vehicletype "]=true if 4 etc...
Run Code Online (Sandbox Code Playgroud)

当我dr["vehicletype "]在 Visual Studio 中看到 的值时,它显示false为 0 和true任何其他值。如何防止它进行默认转换

Jan*_*ano 5

参考:

https://bugs.mysql.com/bug.php?id=67381

您可以在连接字符串中添加“Treat Tiny As Boolean=false;”

现在 tinyint 将被解释为 C# 中的类型 sbyte。