Ejemplo n.º 1
0
        /**
         * A simple CRUD Example
         */
        public static void crudExample()
        {
            // Contact contactNew = new Contact(LastName = 'Jay', Email = '*****@*****.**');
            Contact contactNew = new Contact();

            Soql.Insert(contactNew);
            System.debug(contactNew.Id);
            List <Contact> contacts = Soql.Query <Contact>("SELECT Id, Email FROM Contact WHERE Id = :contactNew.Id", contactNew.Id);

            foreach (Contact c in contacts)
            {
                System.debug(c.Email);
                c.Email = "*****@*****.**";
            }

            Soql.Update(contacts);
            contacts = Soql.Query <Contact>("SELECT Id, Email FROM Contact WHERE Id = :contactNew.Id", contactNew.Id);
            foreach (Contact c in contacts)
            {
                System.debug(c.Email);
            }

            Soql.Delete(contacts);
            contacts = Soql.Query <Contact>("SELECT Id, Email FROM Contact WHERE Id = :contactNew.Id", contactNew.Id);
            if (contacts.isEmpty())
            {
                System.debug("Delete Worked");
            }
        }