dashing
dashing copied to clipboard
Fix InsertOrUpdate inserting second record when there are no dirty props
Fixes #18
What would the expected behaviour be when passing in an untracked entity with a valid primary key? For example, decode an entity from post and then try to insert or update it?
In the mists of time, passing in an untracked entity to save was valid - not sure if this is or should be the case nowadays
Currently, if you have a valid existing PK and call Save() without tracking enabled it will do nothing. It only updates the dirty properties and if tracking is not enabled there will be none.
We always fetch a copy from the DB in a POST update and copy over all the values to update it with before calling Save.
Checking for the existence of a PK is not recommended as it is a 'feature' of Dashing 2 that you can insert an entity with a specific PK.
Without doing a call to see if the PK already exists then I felt this was the safest option - it's very unusual to be manually configuring tracking.