/** * A simple CRUD Example */ public static void CrudExample() { Contact contactNew = new Contact { LastName = "Jay", EMail = "*****@*****.**" }; 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"); } }
/** * 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"); } }
public static void updateContacts(List <Contact> contacts) { Soql.update(contacts); }
private static void UpdateContacts(List <Contact> contacts) { Soql.update(contacts); }