I would kindly ask for some help in creating classes that are based on Database diagrams. I am writing my code in C#. And my main doubt is how to create references from one class to another so that it matches my Database diagrams.
For example, in my Database I have 2 initial tables: Screenplay
and ScreenplayWriter
. Screenplay
has attributes screenplayID, movieID, description
and ScreenPlayWriter
has attributes ScreenplayWriterID, personID
. Then I have the 3rd table which connects these 2 initial tables and this one is called WritesScreenplay
and this table has attributes screenplayID, screenplayWriterID
.
Now I would want to transcribe those tables into C# classes. I am assuming I only need two initial classes Screenplay
and ScreenplayWriter
and that the 3rd one can be derived only as a reference between those initial two. I don't know how to write these references in code so that it makes sense. Note by, one screenplay can have multiple screenplay writers.
Any help would be greatly appreciated. Regards
You can use Entity Framework. It can solve many of your problem if possible.
for your listed problem , ScreenPlay and ScreenPlayWriters has 1 :m relationships
so something like below in which one screenplay object can contain a list of writers
public class ScreenPlay
{
public IList<ScreenPlayWriter> Writers {get;set}
}
public class ScreenPlayWriter
{
}