实体框架中的对象图是什么

jun*_*rig 4 .net entity-framework c#-4.0

我目前正在研究实体框架,尤其是自跟踪实体生成器和POCO实体。我在阅读中遇到过几次“对象图”一词,但没有定义/解释。在实体框架的上下文中什么是“对象图”?

blu*_*tor 5

我认为您的根本问题与EF本身无关。“对象图”是驻留在类实例的内存中的数据结构。例如,如果您有:

public class Person
{
   public string Name { get; set; }
   public Person Manager { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

因此,内存中有一堆东西:

Person monkey = new Person()
                    {
                      Name = "Me",
                      Manager = new Person()
                                    {
                                      Name = "CTO",
                                      Manager = new Person()
                                                    {
                                                      Name = "Chairman",
                                                    }
                                    }
                    };
Run Code Online (Sandbox Code Playgroud)

你将有一个向图保存了我,我的老板,和他的老板。基本上,我们谈论的是数据结构101