gpt4 book ai didi

c# - 'x' 上的 'y' 属性无法设置为 'System.Decimal' 值。您必须将此属性设置为类型为 'System.Boolean' 的非空值

转载 作者:可可西里 更新时间:2023-11-01 07:45:42 25 4
gpt4 key购买 nike

我有一个 MySQL 存储过程,它从名为 tuser 的特定表中选择数据。

我正在使用 EntityFramework6,所以我将过程的结果定义为 tuser 的实体。

enter image description here

当我在 C# 代码中使用该过程时,抛出以下异常:

The 'bIsActive' property on 'tuser' could not be set to a 'System.Decimal' value. You must set this property to a non-null value of type 'System.Boolean'.

我无法理解我想执行的操作与抛出的异常之间的联系。

数据库中的表定义:

CREATE TABLE `tuser` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sUserName` varchar(45) DEFAULT NULL,
`sUserNameMail` varchar(45) DEFAULT NULL,
`sMail` varchar(45) DEFAULT NULL,
`bIsActive` bit(1) DEFAULT b'1')
ENGINE=InnoDB AUTO_INCREMENT=2225 DEFAULT CHARSET=utf8;

ef 中的 bIsActive 定义:

enter image description here

存储过程定义:

CREATE DEFINER=``@`` PROCEDURE `GetActiveUsers`()
BEGIN
select u.* from tuser u
where u.bIsActive=true;
END

执行以下代码行时发生错误:

List<tuser> list = Context.GetActiveUsers().ToList();

内部 GetActiveUsers 代码(自动生成):

public virtual ObjectResult<tuser> GetActiveUsers()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<tuser>("GetActiveUsers");
}

最佳答案

好的,感谢所有回复者。

我仍然不知道问题出在哪里,但是当我从模型中删除 tuser 表并再次添加它时,问题就解决了。

关于c# - 'x' 上的 'y' 属性无法设置为 'System.Decimal' 值。您必须将此属性设置为类型为 'System.Boolean' 的非空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44693058/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com