0

I've got a small project and just after some advice on how to seed and initialize some data. The two main classes are Client and History. There is a one-to-one relationship between these. Within History in addition to properties there are also a number of other classes eg. Family class.

So in the initializer class I can set the value to the properties of the history class but I can't figure out how to access and set the value of the properties within the Family object (which is itself a separate table with it's own ID and the HistoryID as a foreign key.)

var historys = new List<History>
{
   new History {ClientID=2, Hopc="The dog ate my homework"},
   new History {ClientID=1, Hopc="The cat ate the dog"}             
   // new History {ClientID=3, Family????...}
};
Jérôme
  • 13,328
  • 7
  • 56
  • 106

1 Answers1

1

List of history could be initlialized like this:

var historys = new List<History>
{
   new History {ClientID=2, Hopc="The dog ate my homework"},
   new History {ClientID=1, Hopc="The cat ate the dog"}
   new History
   {
        ClientID=3,
        Family = new Family
        {
            Property1 = "value1",
            Property2 = "value2
            //...
        }
    }
};
Ankit
  • 2,448
  • 3
  • 20
  • 33