0

Let's say I'm modelling an organizational hierarchy which consists of Divisions that contain Departments that contain Teams. So Division -> Department -> Team.

While it makes sense for the Division class to contain a collection of Departments, should the Department class contain its parent Division object or just the parent Division's identifier?

I can see how having the parent object immediately available is convenient but I'm concerned about circular references.

3
  • 1
    This is a pretty common occurence with Entity Framework and does not introduce circular dependency problems. Did you have any real problem in mind? Commented Mar 16, 2016 at 15:16
  • Performance mostly. I didn't want a case where I pull a Division and it loads a list of Departments which each load the parent Division which loads the list of Departments again and again. Commented Mar 16, 2016 at 15:17
  • 1
    Don't worry about it, EF is smart enough to handle this scenario. Division would have a collection of Departments, and each of these department would have a reference to that Division object. Commented Mar 16, 2016 at 15:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.