var db = new Database("Server=myServerAddress;Database=myDatabase;Uid=myUsername;Pwd=myPassword;"); var newCustomer = new Customer { FirstName = "John", LastName = "Doe", Email = "[email protected]" }; db.Insert("Customers", "CustomerId", newCustomer);
var db = new Database("Data Source=myDatabase.db;"); var newOrder = new Order { OrderDate = DateTime.Now, CustomerId = 12345, TotalAmount = 49.99 }; db.Insert("Orders", "OrderId", newOrder);In this example, we create a new instance of the Database class and pass in the connection string for a SQLite database. We also create a new Order object and assign values to its properties. Finally, we use the Insert method of the Database class to insert the newOrder data into the Orders table, with the OrderId column as the primary key. Package library: PetaPoco.Core.Sqlite In summary, PetaPoco is a lightweight and easy-to-use database access library that provides support for multiple database engines. In C#, you can use the Insert method of the Database class to perform database insert operations. The package library for PetaPoco depends on the specific database engine being used, such as PetaPoco.Core for general usage or PetaPoco.Core.Sqlite for SQLite.