private void buttonAddNewT_Click(object sender, EventArgs e) { using (NewsContext NewsTable = new NewsContext()) { NewsTable.NewT.Add(new New { Basis = textBoxText.Text, Head = textBoxHead.Text }); NewsTable.SaveChanges(); } }
private void buttonAddComment_Click(object sender, EventArgs e) { using (NewsContext NewsTable = new NewsContext()) { Guid sd = ListNew[Count].Id; New newss = NewsTable.NewT .Where(c => c.Id == sd) .FirstOrDefault(); NewsTable.CommentT.Add(new Comment { Text = textBoxCommentAdd.Text, IdNew = newss }); NewsTable.SaveChanges(); } }