cannot implicitly convert type System.DateTime? to System.DateTime.

来源:互联网 发布:建筑工程用什么软件 编辑:程序博客网 时间:2024/05/18 15:25

userBirthday = entity.UBI_Birthday ;
问题:
cannot implicitly convert type System.DateTime? to System.DateTime.
原因:
在sqlserver中设置了datetime可以为null,但datetime不可以为null,要设置defaultValue
解决方法:
userBirthday = entity.UBI_Birthday ?? DateTime.MinValue;

阅读全文
0 0
原创粉丝点击