Пример #1
0
        public void InsertPersonBenefitAssociations()
        {
            Person Jan  = dataContext.Persons.First(p => p.PersonName == "Jan");
            Person Anna = dataContext.Persons.First(p => p.PersonName == "Anna");
            Person John = dataContext.Persons.First(p => p.PersonName == "John");
            Person Mon  = dataContext.Persons.First(p => p.PersonName == "Mon");

            BenefitList Sportcard = dataContext.BenefitLists.First(b => b.BenefitName == "Sportcard");
            BenefitList Dentist   = dataContext.BenefitLists.First(b => b.BenefitName == "Dentist");

            dataContext.PersonBenefits.InsertOnSubmit(new PersonBenefit {
                Person = Jan, BenefitList = Sportcard
            });
            dataContext.PersonBenefits.InsertOnSubmit(new PersonBenefit {
                Person = Anna, BenefitList = Sportcard
            });
            dataContext.PersonBenefits.InsertOnSubmit(new PersonBenefit {
                Person = Anna, BenefitList = Dentist
            });
            dataContext.PersonBenefits.InsertOnSubmit(new PersonBenefit {
                Person = John, BenefitList = Dentist
            });
            dataContext.PersonBenefits.InsertOnSubmit(new PersonBenefit {
                Person = Mon, BenefitList = Sportcard
            });

            dataContext.SubmitChanges();
            MainDataGrid.ItemsSource = dataContext.PersonBenefits;
        }
 partial void UpdateBenefitList(BenefitList instance);
 partial void DeleteBenefitList(BenefitList instance);
 partial void InsertBenefitList(BenefitList instance);