Advertisement
daegron

dao7

Nov 25th, 2022
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. public class UserDao
  2. {
  3.     private NpgsqlDataSource dataSource;
  4.  
  5.     private UserDao(NpgsqlDataSource dataSource)
  6.     {
  7.         this.dataSource = dataSource;
  8.     }
  9.    
  10.     public User findById(int id)
  11.     {
  12.         var command = newDataSource().CreateCommand("SELECT * FROM TABLE WHERE ID = {id}");
  13.         // execute command etc.
  14.     }
  15.    
  16.     public User findByFirstName(string firstName)
  17.     {
  18.         var command = newDataSource().CreateCommand("SELECT * FROM TABLE WHERE ID = {firstName}");
  19.         // execute command etc.
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement