Suppose there are some records in the database like this:
Id v1 v2 v3
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
And suppose my new records look like this:
Id v1 v2 v3
1 1 2 1
5 5 5 5
Now, I want to insert my new records in this way:
1. Check if the Id exists in the database;
2. If it doesn't exist, insert the record directly;
3. If it exists, detect if the record is the same as the new one. If not, only update the changed values.
Since my real data is really large and contains 50+ variables and I want to make inserting fast, I would like to ask is there any general way to detect if a new record of same Id is different with the existing record in entity framework. I can't do 50+ if
to see which variables have been changed.
Please make sure your solution is applicable to a large data set, Thanks.