ushort mysql,Mysql的CodeFirst:不支持ushort、uint、ulong的字段提示不足

现在应该支持了

@sunkaixuan 不报错了,但是容我再杠一下

6b29c4abb89a0cba323eacaf73b7ad23.png

插入不了MaxValue,发现创ushort这些字段的时候没有将字段标记为Unsigned

手动改了Unsigned后可以插入记录了,将记录读回出来的时候会出现Uint不能转为int

6b29c4abb89a0cba323eacaf73b7ad23.png

namespace OrmTest

{

public class DemoE_CodeFirst

{

public static void Init()

{

Console.WriteLine("");

Console.WriteLine("#### CodeFirst Start ####");

SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()

{

DbType = DbType.MySql,

ConnectionString = Config.ConnectionString3,

InitKeyType = InitKeyType.Attribute,

IsAutoCloseConnection = true

});

db.DbMaintenance.CreateDatabase();

db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1

db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" , TestUInt64 = ulong.MaxValue, TestUInt32 = uint.MaxValue, TestUInt16 = ushort.MaxValue }).ExecuteCommand();

var list = db.Queryable().ToList();

Console.WriteLine("#### CodeFirst end ####");

}

}

public class CodeFirstTable1

{

[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]

public int Id { get; set; }

public string Name { get; set; }

[SugarColumn(ColumnDataType = "Nvarchar(255)")]//custom

public string Text { get; set; }

[SugarColumn(IsNullable = true)]

public DateTime CreateTime { get; set; }

public ulong TestUInt64 { get; set; }

public uint TestUInt32 { get; set; }

public ushort TestUInt16 { get; set; }

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值