Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an Object Graph in the entity framework

I'm currently studying about the entity framework, in particular the self-tracking entity generator and POCO entities. I have come across the term "object graph" a couple of times in my reading but no definition / explanation. What is an "object graph" in the context of the entity framework?

like image 544
junkrig Avatar asked Jun 07 '12 04:06

junkrig


1 Answers

I think your root question has nothing to do with EF itself. An "object graph" is a data structure resident in memory of class instances. For example if you had:

public class Person
{
   public string Name { get; set; }
   public Person Manager { get; set; }
}

and a bunch of things in memory thusly:

Person monkey = new Person()
                    {
                      Name = "Me",
                      Manager = new Person()
                                    {
                                      Name = "CTO",
                                      Manager = new Person()
                                                    {
                                                      Name = "Chairman",
                                                    }
                                    }
                    };

You would have a Directed Graph that holds me, my boss, and his boss. Basically, we're talking about Data Structures 101.

like image 169
bluevector Avatar answered Sep 29 '22 11:09

bluevector