.net - .net c# EF 模型中的空嵌套对象
问题描述
我不明白为什么嵌套对象不为空......
var client = db.Clients.Find(id);
if(client != null) {
client.someNestedObject = null;
var x = client.someNestedObject;
//here, x is NOT NULL!!!??? (its a proxy but not null)
}
嵌套对象模型:
public int id { get; set; }
public virtual Client client { get; set; }
客户型号:
public int id { get; set; }
public string client_name { get; set; }
[ForeignKey("someNestedObject")]
public int id_nested { get; set; }
public virtual NestedObject someNestedObject { get; set; }
解决方案
推荐阅读
- elixir - 使用 Ecto 选择、选择合并和连接
- matplotlib - 是否可以在 matplotlib 图例条目中使用文本作为句柄?
- go - 如何在 Go 中获取指向 Interface{} 底层值的指针
- c# - 如何在 ASP.NET WebAPI 中诊断格式错误的 JObject?
- android - “URI 未注册(设置 | 语言和框架 | 模式和 DTD)”&“属性工具:此处不允许使用上下文”
- r - 如何根据其他数据框中的两个条件创建列?
- php - 如何使用 Eloquent 通过外键值从数据库中获取所有行?
- gradle - 是否可以在 JUnit5/Gradle 中选择使用标签组合注释的测试?
- c# - Algolia - 推送数据
- javascript - 如何在合并另一个属性的值的同时删除具有重复属性值的对象?