14
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 29 Mar 2024
14 points (88.9% liked)
SQL
469 readers
1 users here now
Related Fediverse communities:
- #sql on Mastodon
- #postgresql on Mastodon
- c/PostgreSQL on programming.dev
Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient
founded 1 year ago
MODERATORS
No matter how you tackle this, your front end likely communicates in json and your database in sql.
At the crux of it, your backend has the job of translating between the two without openly exposing the database to the front end (unless security truly doesn't matter for your app)
There's no easy way to get around the fact you simply just have to write logic to mediate between those two languages.
The best way I use to avoid mismatch problems between BE<->DB is I use Code First Entity Framework Core as my ORM, letting my EF Core spec act as the source if truth fir my db schema via automated EF migrations.
This means the only way you get a mismatch is due to merge conflicts not being resolved properly if 2 devs both mutate the db schema at the same time.
C#'s Linq is also the closest first class API I have seen that very closely mimics sql.
I genuinely find Linq queries on Entity Framework easier to write and read than sql.
Yeah Linq is truly unique in programming languages. The fact that I can write a where clause how I would in normal code and it just translates it into SQL is so much nicer than some DSL for filtering
100%, the extremely 1:1 way that c# translates into sql is prolly the closest to what OP wants, I've tried a variety of ORMs and EF Core us hands down the best I've used.
The fact it doubles as a DB Schema manager and migration engine is just icing on the cake. All my database related needs in one spot.
LINQ is remarkable.