[英]Property could not be set to a byte value you must set the property to a non null of type int32
Database is in SQL Server 2005 and the datatype of my column in question is defined as tinyint
(I cannot change this type) 数据库在SQL Server 2005中,我所讨论的列的数据类型定义为
tinyint
(我无法更改此类型)
I have created a model having type as Int32
. 我创建了一个类型为
Int32
的模型。 In read statement system is throwing this error. 在read语句系统中抛出此错误。
Property could not be set to a byte value you must set the property to a non null of type int32
无法将属性设置为字节值,必须将该属性设置为int32类型的非null
I was facing a similar problem for other types, then after checking CLR mapping I corrected them. 我遇到了其他类型的类似问题,然后在检查CLR映射后我更正了它们。 Now I am facing this problem only in case of
tinyint
and smallint
. 现在我只在
tinyint
和smallint
情况下面临这个问题。
From the SQL Server docs you can see that TINYINT
is a 1 byte value which maps into .Net as a byte
type. 从SQL Server文档中可以看到
TINYINT
是一个1字节的值,它作为byte
类型映射到.Net。 SMALLINT
is 2 bytes which become Int16
in .Net. SMALLINT
是2个字节,在.Net中成为Int16
。
So you need to change your model to use the correct types. 因此,您需要更改模型以使用正确的类型。
Simply change property data type from complex entity. 只需从复杂实体更改属性数据类型即可。 In your case change property from int32 to byte .
在你的情况下,将属性从int32更改为byte。
At least it worked for me. 至少它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.