Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UserDao
- {
- public User findById(int id)
- {
- var command = newDataSource().CreateCommand("SELECT * FROM TABLE WHERE ID = {id}");
- // execute command etc.
- }
- public User findByFirstName(string firstName)
- {
- var command = newDataSource().CreateCommand("SELECT * FROM TABLE WHERE ID = {firstName}");
- // execute command etc.
- }
- private NpgsqlDataSource newDataSource()
- {
- return NpgsqlDataSource.Create("Server=mydemoserver.postgres.database.azure.com;" +
- "Username=mylogin@mydemoserver;" +
- "Database=mypgsqldb;" +
- "Port=5432;" +
- "Password=<server_admin_password>");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement