예제 #1
0
        private void InitializeAndPersistPeople(ArubaContext context)
        {
            var grandFather = new ArubaPerson
            {
                Name = "GrandFather",
                Children = new List<ArubaPerson>(),
            };

            var mother = new ArubaPerson
            {
                Name = "Mother",
                Children = new List<ArubaPerson>(),
                Parents = new List<ArubaPerson> { grandFather },
            };

            grandFather.Children.Add(mother);

            var father = new ArubaPerson
            {
                Name = "Father",
                Children = new List<ArubaPerson>(),
            };
            mother.Partner = father;

            var child = new ArubaPerson
            {
                Name = "Child",
                Parents = new List<ArubaPerson> { mother, father }
            };

            mother.Children.Add(child);
            father.Children.Add(child);

            var childOfSingleMother = new ArubaPerson
            {
                Name = "Child",
            };

            var singleMother = new ArubaPerson
            {
                Name = "Single Mother",
                Children = new List<ArubaPerson> { childOfSingleMother },
            };

            childOfSingleMother.Parents = new List<ArubaPerson> { singleMother };

            var childOfDivorcedParents = new ArubaPerson
            {
                Name = "Child",
            };

            var divorcedFather = new ArubaPerson
            {
                Name = "Divorced Father",
                Children = new List<ArubaPerson> { childOfDivorcedParents },
            };

            var divorcedMother = new ArubaPerson
            {
                Name = "Divorced Mother",
                Children = new List<ArubaPerson> { childOfDivorcedParents },
            };

            childOfDivorcedParents.Parents = new List<ArubaPerson> { divorcedFather, divorcedMother };

            var bachelor = new ArubaPerson
            {
                Name = "Bachelor",
            };

            context.People.Add(bachelor);
            context.People.Add(divorcedFather);
            context.People.Add(divorcedMother);
            context.People.Add(singleMother);
            context.People.Add(grandFather);
            context.SaveChanges();
        }
예제 #2
0
        private void InitializeAndPersistPeople(ArubaContext context)
        {
            var grandFather = new ArubaPerson
            {
                Name     = "GrandFather",
                Children = new List <ArubaPerson>(),
            };

            var mother = new ArubaPerson
            {
                Name     = "Mother",
                Children = new List <ArubaPerson>(),
                Parents  = new List <ArubaPerson> {
                    grandFather
                },
            };

            grandFather.Children.Add(mother);

            var father = new ArubaPerson
            {
                Name     = "Father",
                Children = new List <ArubaPerson>(),
            };

            mother.Partner = father;

            var child = new ArubaPerson
            {
                Name    = "Child",
                Parents = new List <ArubaPerson> {
                    mother, father
                }
            };

            mother.Children.Add(child);
            father.Children.Add(child);

            var childOfSingleMother = new ArubaPerson
            {
                Name = "Child",
            };

            var singleMother = new ArubaPerson
            {
                Name     = "Single Mother",
                Children = new List <ArubaPerson> {
                    childOfSingleMother
                },
            };

            childOfSingleMother.Parents = new List <ArubaPerson> {
                singleMother
            };

            var childOfDivorcedParents = new ArubaPerson
            {
                Name = "Child",
            };

            var divorcedFather = new ArubaPerson
            {
                Name     = "Divorced Father",
                Children = new List <ArubaPerson> {
                    childOfDivorcedParents
                },
            };

            var divorcedMother = new ArubaPerson
            {
                Name     = "Divorced Mother",
                Children = new List <ArubaPerson> {
                    childOfDivorcedParents
                },
            };

            childOfDivorcedParents.Parents = new List <ArubaPerson> {
                divorcedFather, divorcedMother
            };

            var bachelor = new ArubaPerson
            {
                Name = "Bachelor",
            };

            context.People.Add(bachelor);
            context.People.Add(divorcedFather);
            context.People.Add(divorcedMother);
            context.People.Add(singleMother);
            context.People.Add(grandFather);
            context.SaveChanges();
        }