Skip to content

Instantly share code, notes, and snippets.

@bertt
Created May 23, 2016 18:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bertt/b61b014c72c5a94b39c2d30497ba7f37 to your computer and use it in GitHub Desktop.
Save bertt/b61b014c72c5a94b39c2d30497ba7f37 to your computer and use it in GitHub Desktop.
Sample .NET Core + Npgsql for RC2
1] Project.json
{
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Npgsql": "3.1.0"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002673",
"type": "platform"
}
}
}
}
}
2] Program.cs:
using System;
using Npgsql;
namespace ConsoleApp1
{
public class Program
{
public static void Main(string[] args)
{
var connString = "Server=192.168.99.100;User Id=pipeline;Password=pipeline;Database=pipeline";
var conn = new NpgsqlConnection {ConnectionString = connString};
conn.Open();
var sql = "select count(*) from wiki_stats_mrel";
var cmd = conn.CreateCommand();
cmd.CommandText = sql;
var count = cmd.ExecuteScalar();
Console.WriteLine("Count: " + count);
conn.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment