Пример #1
0
        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";
        }
Пример #2
0
        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";
        }
Пример #3
0
 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);
     }
 }
Пример #4
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     context.SaveChanges();
 }