查询本地缓存时是否需要安全导航?

时间:2019-11-14 17:18:17

标签: c# entity-framework entity-framework-core ef-core-2.2

当我向真实的数据库查询时

context.Entities.Where(e => e.Owner.Id == ownerId)

我可以肯定不会发生任何错误,因为不会使用任何实际对象,并且这将转换为某些SQL请求。但是本地缓存呢?

context.Entities.Local.Where(e => e.Owner.Id == ownerId)

我可以确定即使我不是Include所有者,也不会抛出NRE吗?还是我应该使用

context.Entities.Local.Where(e => e.Owner?.Id == ownerId)

0 个答案:

没有答案