Help determining the process of updating a record.
Coming from an ORM background with Entity Framework this was the process:
- Retrieve field from the database and populate entity.
- Access the entity object and change the fields you want to update
- Save the entity to the database context, and in the case of Entity Framework, it will go through all your entities, and compare them with their original values, and if any has changed, it will execute an update statement.
What is the approach like when not using an ORM like EF?
I have classes that are a 1:1 mapping to my db schema, so should I follow this same approach when trying to update a record via stored procedure?
I have crafted functionality of accepting an xml parameter in a stored procedure, where I can optionally pass in any piece of data I want for the update, so in reality, I don’t have to get data to conform to one of the aformentioned classes for the update…
For example, if I had a users table with firstname
and lastname
and I only had the need to update firstname. I could just pass firstname
to the stored procedure to update.