[英]Ef Core Reconciler Not Accepting Null Child Entity
I have been using this Reconciler plugin in my dotnet core web application. 我在dotnet核心Web应用程序中一直在使用此Reconciler插件 。
It is similar to GraphDiff but this plugin supports ef core. 它类似于GraphDiff,但此插件支持ef核心。
I have these lines when I'm updating my model. 更新模型时,我有以下几行。
_context.Reconcile(applicationForm, r => r.WithMany(m => m.AccessArea).WithMany(m => m.TrainingRecord));
await _context.SaveChangesAsync();
The problem is, Reconcile() doesn't accept null parameter, so when I pass null child entity it hits error. 问题是,Reconcile()不接受null参数,因此当我传递null子实体时会遇到错误。
AggregateException: One or more errors occurred. (Value cannot be null. Parameter name: source)
Any workaround for this? 任何解决方法?
Much appreciated! 非常感激!
I manage to resolve this by making them an empty list instead of null. 我设法通过使它们为空列表而不是null来解决此问题。
Cheers! 干杯!
if (applicationForm.AccessArea == null)
{
applicationForm.AccessArea = new List<AccessAreaCheckBox>();
}
if (applicationForm.TrainingRecord == null)
{
applicationForm.TrainingRecord = new List<FilePath>();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.