private void buttonInsert_Click(object sender, EventArgs e) { using (var context = new sakilaEntities()) { var friend = new friend { FriendlyName = textBox3.Text }; var anotherFriend = new friend { FriendlyName = textBox3.Text + " Jr." }; var contact = new contact { FirstName = textBox1.Text, LastName = textBox2.Text, friends = new List <friend> { friend, anotherFriend } }; context.contacts.Add(contact); context.SaveChanges(); } Text = @"Success"; }
private void buttonInsert_Click(object sender, EventArgs e) { using (var context = new sakilaEntities()) { var friend = new friend { FriendlyName = textBox3.Text }; var anotherFriend = new friend { FriendlyName = textBox3.Text + " Jr." }; var contact = new contact { FirstName = textBox1.Text, LastName = textBox2.Text, friends = new List<friend> { friend, anotherFriend } }; context.contacts.Add(contact); context.SaveChanges(); } Text = @"Success"; }
private void buttonSave_Click(object sender, EventArgs e) { try { foreach (var c in context.customers.Where(c => c.last_name.StartsWith("s"))) { var person = personDtos.First(p => p.EmailAddress == c.email); var tokens = person.Name.Split(new[] { ' ' }); c.first_name = tokens[0]; c.last_name = tokens[1]; c.email = person.EmailAddress; } context.SaveChanges(); } catch (InvalidOperationException ex) { MessageBox.Show(ex.Message); } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { context.SaveChanges(); }