c# - How do you model a simple composition relationship -


Does someone help me understand how best is the structure relationship to model?

For example, if I can have students who have several programs, I will make them roughly:

  class student {prop lock pk {receives; Set; } Prop string name {get; Set; } Support list & lt; Schedule & gt; Schedules {receive; Set; }} Class schedule {prop string semester {get; Set; } Support list & lt; Curriculum & gt; Course {Get; Set; }}  

Somewhere I can be a schedule object in the bottom line, and she would like to identify which student it belongs to. I want to be able to write in the schedule. Student. Name , and get the name of the student in return Do I also add student property to my schedule?

My application for CRUD functionality is passing on to a student PK in my schedule object. I keep the student PK as a private variable so that if I need it then I can handle it.

Because my application becomes more complicated, I have difficulty in maintaining what I am doing. What are your suggestions for me? How can I consult more and more (book / link) to handle these fundamentals in a refresher and better way?

"I want to be able to write schedule. Student name, and in return the student gets the name Do I add student property to my schedule item too? "Yes.

You look like a very good match for object-relational mapper (ORM) (supporting both foreign keys for lookup and object contexts for easier navigation of the object graph). A good ORM will load the object / object related to you by using the FK / PK (if there is a student PK field in the schedule, then you will handle the loading / mapping of the student). There are many products of this type: you have built-in Can use NET frameworks like open-source ones like commercial products or, or (disclosure: I work for a company that creates commercial ORMs) Check Wikipedia for a review of Google, OR what kind of thing I'm describing for ORM or object-relational mapper.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -