3 ms·
An ORM doesn’t have to be slow. Most can source their data from custom queries or stored procedures. Not using an ORM requires writing lots of code to do what
by fuzzy2 8y ago
An ORM doesn’t have to be slow. Most can source their data from custom queries or stored procedures.
Not using an ORM requires writing lots of code to do what the ORM would otherwise do. Is that really appropriate today? Should we not take advantage of the available CPU/RAM? I say ORM is the correct choice in many cases. Not always.
- blowski 8y agoORM doesn’t have to be slow, but I have seen a lot of implementations like the parent comment. For example, doing a foreach over 2000 rows where an UPDATE would be much, much quicker. ORMs help a lot with developing software, but you need to profile and optimise - in some cases bypassing the ORM.
- TekMol 8y agoI say ORM is the correct choice in many cases I'm still undecided about this. Would be fun to compare some actual approaches. Which is your favorite ORM?
- fuzzy2 8y agoCurrently I’m trying to use Dapper if possible. It allows me to write efficient queries manually and just maps the results to objects. For simple queries though (single-table), Entity Framework is just as fast. Because I’m mostly working on dashboards and stuff, writing to the database isn’t much of a concern.
- TekMol 8y agoWhat is the code to get the number of cars with expired insurence when using Dapper?
- fuzzy2 8y agoSomething along the lines of db.Query<Car>("SELECT * FROM Cars WHERE InsuranceEndDate < @Date", new { Date = DateTime.Now }); /edit: Sorry, missed the "number of". Well, you get the idea. It'd use 'QuerySingle' instead.
- TekMol 8y agoThat does not look very ORMish to me. It might return objects. But isn't one point of an ORM that you tell the ORM which data you want and not what SQL query to send to the DB?
- tfigment 8y agoAlso Dapper fan. I like mapping into objects without code generation and complicated queries are easier to write compared to LINQ if familiar with actual SQL. Only thing I really don't like is bulk inserts as it will do one statement per object. You can still use both Dapper and LINQ at same time but it might confuse others.
- matwood 8y ago> Which is your favorite ORM? jOOQ. Not really an ORM, but handles the tedium of mapping results to an object while letting me write type checked SQL. IMO, it is the best solution for dealing with an RDBMS. I wish every language had a jOOQ equivalent.