Last active
December 13, 2016 02:51
-
-
Save 0xbustos/1fbb87ca9c9888f8e5cdd5de99b11dbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Npgsql; | |
using System.Data; | |
using Dapper; | |
namespace Conexion | |
{ | |
public class DataRetriever : IDisposable | |
{ | |
private String connectionString = "Server=;Port=;User ID=;Password=;Database ;"; | |
private NpgsqlConnection dbConnection; | |
public DataRetriever() | |
{ | |
dbConnection = new NpgsqlConnection(connectionString); | |
dbConnection.Open(); | |
} | |
public IEnumerable<Ciudad> GetCiudades() | |
{ | |
return dbConnection.Query<Ciudad>("select * from ciudad"); | |
} | |
public void Dispose() | |
{ | |
dbConnection.Close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Data Retriever Class with Dapper and PostgreSQL