Пример #1
0
        public void UpdateContact()
        {
            using (PEF context = new PEF())
            {
                var contact = context.Contact.First();
                contact.FirstName    = "Julia";
                contact.ModifiedDate = DateTime.Now;
                context.SaveChanges();
            }



            Console.Write("Press Enter...");
            Console.ReadLine();
        }
Пример #2
0
        public void UpdateContacts()
        {
            using (PEF context = new PEF())
            {
                var contacts = context.Contact.Include("Address")
                               .Where(c => c.FirstName == "Bobby").ToList();
                var contact = contacts[1];
                contact.FirstName = "Marquitos";
                contact           = contacts[2];
                var address = contact.Address.ToList()[0];
                address.Street1 = "Two Main Street";
                context.SaveChanges();
            }



            Console.Write("Press Enter...");
            Console.ReadLine();
        }
Пример #3
0
        public void InsertAdress()
        {
            using (PEF context = new PEF())
            {
                //  Example 6 - 3.Creating a new address in memory
                var contact = context.Contact.Where(c => c.FirstName == "Robert").First();
                var address = new Address();
                address.Street1 = "TRHEE Main Street";
                address.City    = "Colon";

                address.StateProvince = "VH";
                address.AddressType   = "HOME";
                address.ModifiedDate  = DateTime.Now;
                //join the new address to the contact
                address.Contact = contact;
                context.SaveChanges();
            }
            Console.Write("Press Enter...");
            Console.ReadLine();
        }