簡體   English   中英

EF核心協調人不接受空子實體

[英]Ef Core Reconciler Not Accepting Null Child Entity

我在dotnet核心Web應用程序中一直在使用此Reconciler插件

它類似於GraphDiff,但此插件支持ef核心。

更新模型時,我有以下幾行。

_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)

任何解決方法?

非常感激!

我設法通過使它們為空列表而不是null來解決此問題。

干杯!

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM