News for hackers. Stuff that matters.
Re:Objection to ORM Hatred by 5e92cb50239222b on Monday January 16, 2023 @02:06AM (#34397765)
(probably) not many are using ORMs because "SQL is hard". You're attacking a strawman. I use ORMs because they make two things incredibly easy:

- saving object graphs: it's trivial to write SQL for a simple CRUD form. It's far more difficult to work with real models where you have to deconstruct the form the user posted into a dozen tables with joins between them, doing insert/update/delete as needed. With a decent ORM you simply construct an object graph by assigning fields (the result can be very complicated), shove that into the database, and the ORM takes care of the rest. It may not be web scale™, but many of us don't need that.

- constructing queries on the fly: if you ever get any exposure to LINQ, I don't think you'll want to go back to SQL after that. It allows you to easily construct queries based on user input (in a type-safe way, unlike some other solutions), which saved me countless hours when building complicated tables with search and filtering on many (sometimes hundreds) of fields.

Here is a trivial example: https://stackoverflow.com/a/10884757

And with good ORMs like Entity Framework the underlying queries they generate are predictable.

Re:Objection to ORM Hatred by ChymeraXYZ on Monday January 16, 2023 @02:41AM (#34397963)
> And with good ORMs like Entity Framework the underlying queries they generate are predictable.

Right up until they are not and generate crap. I went from "predictable" EF generated queries to handcrafted ones reduced the load on the DB by about 70% while having more queries per second...

Re:Objection to ORM Hatred by asabla on Monday January 16, 2023 @05:04PM (#34406059)
from personal experience this was a much larger problem during .net framework days. Now with EFcore, most generated queries are much more sane and performant
Re:Objection to ORM Hatred by Foobar8568 on Monday January 16, 2023 @02:10AM (#34397793)
So much this. I hate micro-ORM, they lost the relational part of RDBMS.
Re:Objection to ORM Hatred by sam_lowry_ on Monday January 16, 2023 @03:12AM (#34398170)
A very popular alternative is to inject json in the DB.
Re:Objection to ORM Hatred by chillfox on Monday January 16, 2023 @03:37AM (#34398349)
I only end up doing that when using an ORM to work around the limitations. I have never needed to do it when just using SQL.
Re:Objection to ORM Hatred by chillfox on Monday January 16, 2023 @03:35AM (#34398335)
I find that ORMs makes it significantly harder to construct queries for anything but the most basic of queries. I routinely end up having to fight the ORM.
Re:Objection to ORM Hatred by throwawaymaths on Monday January 16, 2023 @10:20AM (#34401488)
Linq is not really an orm, though. I think it's a "query builder"