Skip to content

Instantly share code, notes, and snippets.

@0xbustos
Last active December 13, 2016 02:51
Show Gist options
  • Save 0xbustos/1fbb87ca9c9888f8e5cdd5de99b11dbc to your computer and use it in GitHub Desktop.
Save 0xbustos/1fbb87ca9c9888f8e5cdd5de99b11dbc to your computer and use it in GitHub Desktop.
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();
}
}
}
@0xbustos
Copy link
Author

Data Retriever Class with Dapper and PostgreSQL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment