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...
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.
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.
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"
- 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.