Advertisement
daegron

dao6

Nov 25th, 2022
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. public class UserDao
  2. {
  3.     public User findById(int id)
  4.     {
  5.         var command = newDataSource().CreateCommand("SELECT * FROM TABLE WHERE ID = {id}");
  6.         // execute command etc.
  7.     }
  8.    
  9.     public User findByFirstName(string firstName)
  10.     {
  11.         var command = newDataSource().CreateCommand("SELECT * FROM TABLE WHERE ID = {firstName}");
  12.         // execute command etc.
  13.     }
  14.  
  15.     private NpgsqlDataSource newDataSource()
  16.     {
  17.         return NpgsqlDataSource.Create("Server=mydemoserver.postgres.database.azure.com;" +
  18.            "Username=mylogin@mydemoserver;" +
  19.            "Database=mypgsqldb;" +
  20.            "Port=5432;" +
  21.            "Password=<server_admin_password>");
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement