字符串格式 : server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=haosql
注意:
.net core 或者 Net5 请用 sqlSugarCore.MySqlConnector 替换 sqlSugarCore
Freamework 用户不受影响
推荐: 8.0.21和6.9.12
解决办法3选1:
1、将该字段的缺省值设置为null,而不是0000-00-00/0000-00-00 00:00:00的情况;
2、在链接MySQL的字符串中添加:Convert Zero Datetime=True 和 Allow Zero Datetime=True两个属性;
3、将该字段设置成字符串类型;
.net framework 4.5.2 | 需要安装MySql.Data 8.0以上版本 |
. net core 2.0+ | 驱动会自动安装 |
[SugarColumn(ColumnDataType = "DATETIME(3) ")] public DateTime CreateTime { get; set; }
驱动的DataReader.GetDateTime()是不支持查出毫秒的,所以你要查毫秒代码需要这么处理:
Select(it=>new { CreateTime=it.CreateTime.ToString() //转成string就能查出带毫秒的时间 });
[SugarColumn(ColumnDataType = "DATETIME(3) ")] public string CreateTime { get; set; } //直接用string
特殊服务器不支持 N'xx' 这种 Narchar插入
MySQL表情可能也不能使用N进行插入
DbType = SqlSugar.DbType.MySql, ConnectionString = Config.ConnectionString, InitKeyType = InitKeyType.Attribute, IsAutoCloseConnection = true, MoreSettings=new ConnMoreSettings() { MySqlDisableNarvchar=true //这里设置为true },
2016 © donet5.comApache Licence 2.0