var db = new PetaPoco.Database(""); var customer = db.FirstOrDefault ("SELECT * FROM Customers WHERE Id = @0", customerId); if (customer != null) { customer.Name = "John Doe"; db.Update(customer); Console.WriteLine("Customer record updated."); } else { Console.WriteLine("Customer not found."); }
var db = new PetaPoco.Database("This example demonstrates how to update multiple customer records at once using a SQL query with a `WHERE` clause. The `Update` method takes the SQL query as the first argument and additional parameters for any placeholders in the query. It returns the number of affected rows, which is then printed to the console."); var affectedRows = db.Update ("SET Name = @0 WHERE Age > @1", "John Doe", 30); Console.WriteLine("{0} customer records updated.", affectedRows);