private void button2_Click(object sender, EventArgs e) { pBaseEntities pb = new pBaseEntities(); LData md = new LData(); testsparam tst = pb.testsparams.First(t => t.idt == (int)EnumPTests.NPNA); tst.answersparams.Load(); for (int a = 0; a < tst.answerscount; a++) { answersparam ap = answersparam.Createanswersparam(0, tst.idt, "Вопрос № " + (a + 1), 2); ap.num = a + 1; ap.buttondescription = md.answers[a].text; ap.intercellswidth = 27; ap.cellshight = 25; ap.cellswidth = 25; ap.toplx = 0; ap.toply = 0; ap.toprx = 0; ap.topry = 0; ap.blx = 0; ap.bly = 0; ap.brx = 0; ap.bry = 0; cellsparam cp = cellsparam.Createcellsparam(0, ap.ida); cp.description = "Да"; cp.buttonsescription = "Да"; cp.mark = 1; cellsparam cp1 = cellsparam.Createcellsparam(0, ap.ida); cp1.description = "Нет"; cp1.buttonsescription = "Нет"; cp1.mark = 0; ap.cellsparams.Add(cp); ap.cellsparams.Add(cp1); tst.answersparams.Add(ap); } // pb.testsparams.AddObject(tst); // pb.SaveChanges(); }