【问题标题】:Ef Core Reconciler Not Accepting Null Child EntityEf Core Reconciler 不接受空子实体
【发布时间】:2019-08-02 03:54:36
【问题描述】:

我一直在我的 dotnet 核心 Web 应用程序中使用这个 Reconciler plugin

类似于GraphDiff,但是这个插件支持ef core。

当我更新我的模型时,我有这些线条。

_context.Reconcile(applicationForm, r => r.WithMany(m => m.AccessArea).WithMany(m => m.TrainingRecord));
await _context.SaveChangesAsync();

问题是,Reconcile() 不接受 null 参数,所以当我传递 null 子实体时会出错。

AggregateException: One or more errors occurred. (Value cannot be null. Parameter name: source)

有什么解决方法吗?

非常感谢!

【问题讨论】:

    标签: c# asp.net-core web-applications .net-core ef-core-2.2


    【解决方案1】:

    我设法通过将它们设为空列表而不是 null 来解决此问题。

    干杯!

    if (applicationForm.AccessArea == null)
    {
        applicationForm.AccessArea = new List<AccessAreaCheckBox>();
    }
    if (applicationForm.TrainingRecord == null)
    {
        applicationForm.TrainingRecord = new List<FilePath>();
    }
    

    【讨论】:

      猜你喜欢
      • 2023-02-04
      • 1970-01-01
      • 2018-04-05
      • 1970-01-01
      • 2021-02-16
      • 1970-01-01
      • 2020-04-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多