News for hackers. Stuff that matters.
Re:What ORMs have taught me: just learn SQL (2014) by wvenable on Friday September 20, 2019 @10:04PM (#21033033)
Your example makes for good SQL but a simple ORM example:

    employee = new Employee() { Name = "Bob" }
    employee.Manager = new Employee() { Name = "Jill" }
    context.Employees.Add(employee)
    context.SaveChanges()
This would insert a new employee record for Jill, grab the primary key, then insert the record for Bob with his ManagerId field to Jill's id. If Bob wasn't a new employee, it would perform and update instead. If there were more related elements and different levels of depth the ORM would order the inserts/updates to get the necessary keys and wire everything up. After this block of code, the objects are all updated with their new primary key values. Everything is executed in a single transaction.

The ORM is performing operations on objects -- it's pretty much right there in the name -- it's going to be a poor choice for bulk updates because that's not what it's for. But again, nothing stops you from using the right tool for the right job -- whether that be an ORM or raw SQL.

There are no comments on this comment yet.