'promotionschedule'上的'promotionschedule'属性无法设置为'null'值。您必须将此属性设置为类型为“system.int64”的非null值。 [英] The 'promotionschedule' property on 'promotionschedule' could not be set to a 'null' value. You must set this property to a non-null value of type 'system.int64'.

查看:390
本文介绍了'promotionschedule'上的'promotionschedule'属性无法设置为'null'值。您必须将此属性设置为类型为“system.int64”的非null值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

List<PromotionSchedule> schedule=db.PromotionSchedule.Where(t => t.PromotionsId == id).ToList();





在执行上述声明时,我们可以收到错误,例如

'promotionchedule 'PromotionSchedule'上的'property'无法设置为'null'值。您必须将此属性设置为'System.Int64'类型的非null值。





请帮帮我

谢谢你。



我尝试过:



在执行上述声明时,我们可以收到类似
$ b $的错误b'PromotionSchedule'上的'promotionschedule'属性无法设置为'null'值。您必须将此属性设置为'System.Int64'类型的非null值。



while executing the above statment we can get the error like
"The 'promotionschedule' property on 'PromotionSchedule' could not be set to a 'null' value. You must set this property to a non-null value of type 'System.Int64'."


Please help me
thank u.

What I have tried:

while executing the above statment we can get the error like
"The 'promotionschedule' property on 'PromotionSchedule' could not be set to a 'null' value. You must set this property to a non-null value of type 'System.Int64'."

推荐答案

鉴于缺少代码,这是最好的路线和最可能的原因。


PromotionSchedule是数据库中的一个表。看起来您正在使用实体框架,因此映射到PromotionSchedule表的实体在该表中具有promotionchedule列。在该表中,此列必须是可以为空的整数,但是您的实体映射必须将其作为不可为空的整数,这就是您遇到运行时错误的原因。


您需要使PromotionSchedule表中的列不可为空(如果sql server需要重建表),或者您需要将promotionschedule列的实体映射更改为可为空的int。因此将其更改为 Nullable< int> promotionschedule 因为它当前可能是 int promotionschedule
Given the lack of code here is the best route and most likley cause.

PromotionSchedule is a table in your database. It looks as though you are using entity framework so the entity mapping to PromotionSchedule table has a promotionschedule column in that table. Within that table, this column must be a nullable integer but your entity mapping must have it as a non-nullable integer which is why you are getting a run time error.

You either need to make the column in your PromotionSchedule table non-nullable (Requires rebuilding the table if sql server) or you need to change the entity mapping for promotionschedule column to be a nullable int. So changing it to Nullable<int> promotionschedule as it probably currently is int promotionschedule


这篇关于'promotionschedule'上的'promotionschedule'属性无法设置为'null'值。您必须将此属性设置为类型为“system.int64”的非null值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆