Is it possible to use LinqToSql with PostgreSQL (preferably with Mono)? Can you recommend any articles where it described step-by-step?
No, LINQ to SQL works only with MS SQL Server. You have to use 3-rd party provider to access PostgreSQL datasource.
PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.
I use LINQ to SQL since about 2 years with MySQL and PostgreSQL databases (using DbLinq on Windows, using Mono on Linux and Mac OS X).
So LINQ to SQL is NOT limited to SQL Server, but as stated above, you need to use external libraries.
On Mono, DbLinq is the foundation of the System.Data.Linq namespace: you don't need to deploy/register DbLinq assemblies. Idem for the Npgsql assembly: it is already provided by the latest versions of Mono.
You should be aware that the support is incomplete (I had numerous problems when I tried to bind an ObjectDataSource control to a PostgreSQL data context: I solved them by doing manual data binding with the generated entities). But this is enough for most SQL queries (I've almost never had any failed queries : complex joints can be simulated by several simpler queries).
There is little difference between DbLinq and LINQ to SQL. Only the connection string must be customized by supplying informations about the data provider. See these short samples (I never found any real tutorial about the use of DbLinq):
http://www.mono-project.com/Release_Notes_Mono_2.6
http://www.jprl.com/Blog/archive/development/mono/2009/Mar-12.html
Personally, with Mono 2.10.6, I use this type of connection string : "Server=localhost; Database=MyDB; User Id=postgres; Password=MyPassword; DbLinqProvider=PostgreSql; DbLinqConnectionType=Npgsql.NpgsqlConnection, Npgsql, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"
Note: on Mono, the DbMetal tool is replaced by the "sqlmetal" command, which has the same parameters (it's just a wrapper around DbMetal).
Not out of the box. You'd have to find a third party that has written a provider for PostgreSQL.
One such provider is DbLinq. Instructions for installation and use may be found here.
Please note, that as of 2016 year DbLinq project is mooved to github, archived and not maintained anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With