/** * 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 SqlReadAndInsert() { OrmLiteConfig.DialectProvider = SqliteDialect.Provider; using (IDbConnection db = "db.sqlite".OpenDbConnection()) { db.CreateTable <Account>(true); //CreateAllTables(db, true); List <Account> accountList = SoqlApi.Query <Account>(1); Console.WriteLine(accountList[0].Dump()); accountList[0].Name = Guid.NewGuid().ToString(); db.InsertAll(accountList); var account = db.Select <Account>(x => x.Name == accountList[0].Name).FirstOrDefault(); Console.WriteLine(account.Dump()); Soql.Update(account); account = Soql.query <Account>("SELECT Id, Name FROM Account WHERE Name = :account.Name", account.Name); Console.WriteLine(account.Dump()); } }
public static void updateContacts(List <Contact> contacts) { Soql.Update(contacts); }