从字符串转换日期和/或时间时转换失败 [XAF ListViewFilter]

Kir*_*eed 0 xaf entity-framework-core .net-core

我使用 XAF 21.2.5 从框架升级到 .NetCore

现在,如果我尝试使用以下 ListViewFilter

 [ListViewFilter("Today",
        "[Created] >= LocalDateTimeToday()",
        "Today", true, Index = 0)]
Run Code Online (Sandbox Code Playgroud)

在我的具有属性的业务对象上

public DateTime Created { get; set; }
Run Code Online (Sandbox Code Playgroud)

我收到一个错误

  Microsoft.Data.SqlClient.SqlException
  HResult=0x80131904
  Message=Conversion failed when converting date and/or time from character string.
  Source=Core Microsoft SqlClient Data Provider
  StackTrace:
   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
Run Code Online (Sandbox Code Playgroud)

文档表明这应该有效

[更新]

读完这个问题后我开始尝试

modelBuilder.Entity<MyEntity>().Property(x => x.Created).HasColumnType("datetime");
Run Code Online (Sandbox Code Playgroud)

我正在寻找可为空的属性,以便映射所有日期时间属性。

Kir*_*eed 6

解决方案是将以下内容添加到 OnModelCreating

modelBuilder.Entity<MyEntity>().Property(x => x.Created).HasColumnType("datetime");
Run Code Online (Sandbox Code Playgroud)

并仔细检查实体中每个声明的属性,以确保它是否可以正确设置为空

我有一个int?错误地声明为 int