我正在使用小巧的扩展(SqlMapperExtensions.cs)。
进行简单插入时:
db.Insert<Student>(student);
我得到一个例外:
Object of type 'System.Int32' cannot be converted to type 'System.Int16'.
db 中的 Id 类型是 SmallInt。
POCO 中的 Id 类型是 Short。
当我在 Catch 块中设置断点时,我可以看到数据已成功保存到数据库。似乎问题在于方法返回并尝试将创建的新 Id 设置到 POCO 中。
当我将 POCO 中的 Id 类型更改为 Int时,它可以工作。
这是一个错误吗?我错过了什么?