EF Changetracker可以告诉您最初是否有一个收藏品?
考虑以下简单情况。
class Adult
{
public List<Children> Children { get; private set; }
}
如果您通过了由实体框架跟踪的父母实例,并且此实例有一个空的儿童列表,您是否可以通过编程方式确定孩子的收集是否为空,因为父母实际上没有孩子或是否有孩子空列表是由于这些数据没有被获取吗? 我认为EF具有某种形式的知识,因为我们应该能够在不取孩子并更改父母的情况下检索父母。名称等,并调用savechanges而无需删除EF的savechanges在保存时为空。
我已经研究了跟踪性和实体,但我看不到如何做出这一决定。
Consider the following simple case.
class Adult
{
public List<Children> Children { get; private set; }
}
If you are passed an instance of Parent that is tracked by Entity Framework and this instance has an empty list of children, is there any way that you can programatically determine if the Children collection is empty due to the parent actually not having children or if the empty list is due to these data not being fetched?
I assume that EF has some form of knowledge of it, since we are supposed to be able to retrieve a parent without fetching the children and make changes to Parent.Name and such and invoke SaveChanges without EF deleting the children just because the Children collection is empty at the time of save.
I've looked at TrackedEntities and EntityStates, but I don't see how to make this determination.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
和
and