Guest User

Untitled

a guest
Dec 11th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. private static void PetaPocoExamples()
  2. {
  3. Console.WriteLine("Running PetaPoco examples");
  4.  
  5. var petapoco = new Database(SqlHelper.ConnectionString, "System.Data.SqlClient");
  6. petapoco.OpenSharedConnection();
  7.  
  8. // CREATE
  9. petapoco.Execute(SqlHelper.CreateStatementWithIndexedParams, SqlHelper.TestId, SqlHelper.InsertCompanyName);
  10.  
  11. // READ with all default options
  12. List<Customer> customer1 = petapoco.Fetch<Customer>(SqlHelper.ReadStatementWithIndexedParams,
  13. SqlHelper.TestId);
  14.  
  15. // READ with some "smart" functionality disabled
  16. var petapocoFast = new Database(SqlHelper.ConnectionString, "System.Data.SqlClient");
  17. petapocoFast.OpenSharedConnection();
  18. petapocoFast.EnableAutoSelect = false;
  19. petapocoFast.EnableNamedParams = false;
  20. petapocoFast.ForceDateTimesToUtc = false;
  21. List<Customer> customer2 = petapocoFast.Fetch<Customer>(SqlHelper.ReadStatementWithIndexedParams,
  22. SqlHelper.TestId);
  23.  
  24. // UPDATE
  25. petapoco.Execute(SqlHelper.UpdateStatementWithIndexedParams, SqlHelper.TestId, SqlHelper.UpdateCompanyName);
  26.  
  27. // DELETE
  28. petapoco.Execute(SqlHelper.DeleteStatementWithIndexedParams, SqlHelper.TestId);
  29. }
Add Comment
Please, Sign In to add comment