I\'m looking at working on a project which uses C#.NET (sitting on a windows box) as the primary language and PostgreSQL as the backend database (backend is sitting on a linux b
Dont let a lack of Linq support stop you. A pattern I use is to always return my data into lists, and then linq away. I started doing this religiously when I found that the same (admittedly obscure) Linq expression in MySQL didnt bring back the same data as it did in Sql Server.
Npgsql - .Net Provider for PostGreSQL - is an excellent driver. If you have used the more traditional ADO.NET framework you are really in luck here. I have code that connects to Oracle that looks almost identical to the PostGreSQL connections. Easier to transition off of Oracle and reuse brain cells.
It supports all of the standard things you would want to do with calling SQL, but it also supports calling Functions (stored procedures). This includes the returning of reference cursors. The documentation is well written and provides useful examples without getting philosophical or arcane. Steal the code right out of the documentation and it will work instantly.
Francisco Figueiredo, Jr's and team have done a great job with this.
It is now available on Github.
https://github.com/franciscojunior/Npgsql2
The better site for info is: http://npgsql.projects.postgresql.org/
Read the documentation! http://npgsql.projects.postgresql.org/docs/manual/UserManual.html
Just Go to Tool-->NuGet Package Manager-->Manager Nuget Package Manager
search for NpgSql and then select your project and click Install
sample Code
public void Demo()
{
NpgsqlConnection connection = new NpgsqlConnection();
connection = d_connection; // your connection string
connection.Open();
NpgsqlCommand cmd = new NpgsqlCommand();
try
{
cmd.Connection = connection;
cmd.CommandText = "select * from your table name";
cmd.CommandType = System.Data.CommandType.Text;
using (var dataReader = cmd.ExecuteReader())
{
while (dataReader.Read())
{
string answer= dataReader.IsDBNull(0) ? "" : dataReader.GetString(0);
}
dataReader.Dispose();
}
}
catch (Exception e)
{
}
finally
{
cmd.Dispose();
connection.Dispose();
}
}
Dont use upper case in postgreSql because its case sensitive.