chgsh_2008 2014-10-15 03:06 采纳率: 0%
浏览 1872

请问下大家有没遇到EF调用GetValidationErrors时出错

请问下大家有没遇到EF调用GetValidationErrors时出错,我知道报错是说未将对象设置为引用对象,但我不明白为什么调用GetValidationErrors时里面报错。错误代码如下:
error message:Object reference not set to an instance of an object., the UniqueReference value is :1334241M01. We will move this file.]
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Entity.Core.Objects.EntityEntry.DetectChangesInProperty(Int32 ordinal, Boolean detectOnlyComplexProperties, Boolean detectOnly)
at System.Data.Entity.Core.Objects.EntityEntry.DetectChangesInProperties(Boolean detectOnlyComplexProperties)
at System.Data.Entity.Core.Objects.ObjectStateManager.DetectChangesInScalarAndComplexProperties(IList1 entries)
at System.Data.Entity.Core.Objects.ObjectStateManager.DetectChanges()
at System.Data.Entity.Core.Objects.ObjectContext.DetectChanges()
at System.Data.Entity.Internal.InternalContext.DetectChanges(Boolean force)
at System.Data.Entity.Internal.InternalContext.GetStateEntries(Func
2 predicate)
at System.Data.Entity.Internal.InternalContext.GetStateEntries()
at System.Data.Entity.Infrastructure.DbChangeTracker.Entries()
at System.Data.Entity.DbContext.GetValidationErrors()
at Ligentia.DataTool.ClientLibraries.OfficeWorks.JobImportShipmentData.getDbError(Ligentix4Entities L4Entities)。
其中getDbError是我自己写的方法。其余都是调用微软的EFContext.GetValidationErrors()时报错了。但在调用GetValidationErrors()方法前,我有判断调用的对象不是为空了,如:
if (l4Entities != null)
{
IEnumerable validationResults =l4Context.GetValidationErrors();
}
请教大家帮帮忙看下为什么啊?谢谢大家

  • 写回答

1条回答

  • q107770540 2014-12-08 02:53
    关注

    System.NullReferenceException: Object reference not set to an instance of an object.

    空引用了,debug看一下具体出错在哪一行

    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿