gpt4 book ai didi

entity-framework - 'XXX' 上的 'XXX' 属性无法设置为 'null' 值。您必须将此属性设置为 'System.DateTime' 类型的非空值

转载 作者:行者123 更新时间:2023-12-05 01:24:29 32 4
gpt4 key购买 nike

我正在 lambda 表达式中编写一个选择查询,其中列名 (ResolveDate) 之一为空,我收到以下错误:

The 'ResolveDate' property on 'Ticket' could not be set to a 'null' value. You must set this property to a non-null value of type 'System.DateTime'.

如何将此列设置为可为空?我的意思是,如果我的查询结果中的列为空,它不应该给出错误?

最佳答案

DateTime 是一个引用类型。您需要在类里面使用 Nullable DateTime。

DateTime? ResolveDate = null;

Nullable<DateTime> ResolveDate ;

关于entity-framework - 'XXX' 上的 'XXX' 属性无法设置为 'null' 值。您必须将此属性设置为 'System.DateTime' 类型的非空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20800273/

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