Hacker News new | ask | show | jobs
by banashark 334 days ago
>> Can you use LINQ against databases like Postgres on Linux, without having to buy into a lot of Microsoft/.NET stuff?

>Probably not. This is usually done with EF Core and the Postgres provider.

You can use Npgsql[0] alone or with non-EF Core interfaces, since it's just a ADO.NET Data Provider (for others: the common interface for database access in dotnet).

The GP question is interesting because it asks about using LINQ with databases "without having to buy into a lot of Microsoft/.NET stuff". I'm going to assume they mean "without using all-microsoft-sourced libraries and frameworks like Entity Framework" (since LINQ is a .NET library interface thing anways).

A couple of example of alternatives that support utilizing Npgsql for database access:

1. Linq2DB: https://linq2db.github.io

2. Dapper: https://github.com/DapperLib/Dapper?tab=readme-ov-file#will-...

3. SqlHydra: https://github.com/JordanMarr/SqlHydra?tab=readme-ov-file#co...

There are a number of other libraries, some more or less complete/maintained than others. EF and Dapper are by far the most popular libraries folks are using on top of Postgres, but there are alternatives, and using the ADO interface on its own works fine (I've done this in very small projects to limit dependencies).

[0] https://www.npgsql.org/doc/index.html