小编Mar*_*uta的帖子

"Y"上的"X"属性无法设置为"null"值.您必须将此属性设置为"Int32"类型的非null值

当我运行我的应用程序并单击特定按钮时,我收到错误:

"The "X" property on "Y" could not be set to a 'null' value. You must set this property to a non-null value of type 'Int32'."
Run Code Online (Sandbox Code Playgroud)

好吧,我转到我的Entity项目,转到Y表,找到X列,右键单击并转到X的属性,发现Nullable设置为False.

我在SQL中验证在Y表中,X被设置为允许空值,并且它是.

然后我回到我的Entity项目,将Nullable设置为True,保存并构建,我收到:

Error 3031: Problem in mapping fragments starting at line 4049:Non-nullable column "X" in table "Y" is mapped to a nullable entity property.
Run Code Online (Sandbox Code Playgroud)

我听说从.edmx文件中删除该表然后重新添加它是一种可能性,但从未这样做过,并且不明白其含义足以令人感到舒服.

我听说它可能在视图中,可能在存储过程中......

也听说这是一个bug.

有没有人遇到过这个并发现了一个"全面"修复或某种路线图,在哪里寻找这个错误?

谢谢!

sql entity-framework visual-studio-2010

25
推荐指数
2
解决办法
5万
查看次数

将IQueryable列表转换为通用列表?

我正在尝试调用GetScanningLogOnSettings(),查询ScanningDepartments表以获取部门,然后创建实例ApplicationLogOnModel,将查询结果分配给其中的变量ApplicationLogOnModel,并返回结果.

private ApplicationLogOnModel GetScanningLogOnSettings()
   {
       var mesEntity = new MESEntities();
       var departments = from dept in mesEntity.ScanningDepartments
                         select dept.Department.ToList();

       ApplicationLogOnModel depts = new ApplicationLogOnModel()
       {
           Department = departments
       };

       return depts;
   }
Run Code Online (Sandbox Code Playgroud)

它给了我:

"无法隐式转换 'System.Linq.IQueryable<System.Collections.Generic.List<char>>'System.Collections.Generic.List<Models.Department>'

尝试转换为列表,我遇到了一些麻烦.

c# asp.net-mvc linq-to-entities

3
推荐指数
1
解决办法
5556
查看次数

如果在.aspx页面中声明

我试图在我的.aspx页面上的一些Javascript中包含一个If语句.

我在页面开头声明FinishedPacking为False.然后,当用户单击orderSubmit按钮时,if语句将评估该值是否确实为false,如果是,则显示警报.到目前为止,if语句不起作用.如果我只使用带有no if语句的alert,它会显示警告:

    var FinishedPacking = false;

    $("#orderSubmit").click(function (e) {
       if (FinishedPacking = false) {
       alert("The order is not finished.")
       }
       ClearScreen();
       GetOrder();
    }):
Run Code Online (Sandbox Code Playgroud)

如上所述,如果我不包含if语句,则单击订单按钮时​​警报会起作用.不知道为什么这个简单的If语句没有被选中.

html javascript

2
推荐指数
1
解决办法
250
查看次数