gpt4 book ai didi

c# - 林克 "Object reference not set to an instance of an object."

转载 作者:行者123 更新时间:2023-11-30 17:36:13 25 4
gpt4 key购买 nike

<分区>

我对这个有点迷茫。获取错误 Object reference not set to an instance of an object. on the line db.EntityRichContents.DeleteAllOnSubmit(q); 在运行时。项目构建良好。

protected override void ControllerOnEntityDeleted(EntityObj forEntity, EntityDeletionController.DeletionAction newStatus)
{
if (newStatus == EntityDeletionController.DeletionAction.HardDelete)
{
if(forEntity == null) throw new Exception();

using (var db = new DBContext())
{
var q = db.EntityRichContents.Where(c => c.C3Entity == ForEntity.TypeID && c.C3EntityRecordID == ForEntity.ID);
db.EntityRichContents.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
}

检查 q.Any()q == null 没有任何帮助(q 不为 null)。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com