vb.net - Entity Framework Conceptual Clarification -


this question purely conceptual! the code below works fine, can't figure out how . . .


the scenario

i've begun reading on entity framework concepts, , i'm using information , examples located here build first mvc project. here's code example link:

    imports system.collections.generic     imports system.data.entity      namespace mydataaccessdemo          module program              sub main()                  using context new productcontext()                      dim food new category {.categoryid = "food"}                     context.categories.add(food)                      dim cheese new product {.name = "cheese"}                     cheese.category = context.categories.find("food")                       context.products.add(cheese)                     context.savechanges()                 end using              end sub          end module          public class productcontext : inherits dbcontext              public property products dbset(of product)             public property categories dbset(of category)          end class           public class product              public property productid integer             public property name string             public property category category ' <-- circular reference?          end class          public class category              public property categoryid string             public property name string             public property products icollection(of product) ' <-- circular reference?          end class     end namespace 

the problem

so, "category" class , "product" class. category contains collection of products, each product of contains category, contains collection of products, each product of contains category, contains collection of products . . . well, idea.


the question

why work? shouldn't cause kind of circular reference? think category contain product ids , vice versa, not objects themselves.

those called navigation properties, can find out more information here on entity framework website.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -