Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void PetaPocoExamples()
- {
- Console.WriteLine("Running PetaPoco examples");
- var petapoco = new Database(SqlHelper.ConnectionString, "System.Data.SqlClient");
- petapoco.OpenSharedConnection();
- // CREATE
- petapoco.Execute(SqlHelper.CreateStatementWithIndexedParams, SqlHelper.TestId, SqlHelper.InsertCompanyName);
- // READ with all default options
- List<Customer> customer1 = petapoco.Fetch<Customer>(SqlHelper.ReadStatementWithIndexedParams,
- SqlHelper.TestId);
- // READ with some "smart" functionality disabled
- var petapocoFast = new Database(SqlHelper.ConnectionString, "System.Data.SqlClient");
- petapocoFast.OpenSharedConnection();
- petapocoFast.EnableAutoSelect = false;
- petapocoFast.EnableNamedParams = false;
- petapocoFast.ForceDateTimesToUtc = false;
- List<Customer> customer2 = petapocoFast.Fetch<Customer>(SqlHelper.ReadStatementWithIndexedParams,
- SqlHelper.TestId);
- // UPDATE
- petapoco.Execute(SqlHelper.UpdateStatementWithIndexedParams, SqlHelper.TestId, SqlHelper.UpdateCompanyName);
- // DELETE
- petapoco.Execute(SqlHelper.DeleteStatementWithIndexedParams, SqlHelper.TestId);
- }
Add Comment
Please, Sign In to add comment