If that's your only performance problem, you're an happy man ;)Thanks @Raphaël Althaus, very valid point.
Usually in batch processes you need to load the data anyways at the time the service runs.If the updated user no longer has reference to something, it would not be right to replace it with the original value if you meant to clear it.I have added an extra update method onto my repository base class that's similar to the update method generated by Scaffolding.Model validation is controlled in the Model State, not in the context.This example is referencing an existing user, hence "updated User".Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Instead of setting the entire object to "modified", it sets a set of individual properties.
(T is a class generic parameter.) I like one trip to the database.
Let's say you have a very short list of properties that you wouldn't want to ever include in a View, so when updating the entity, those would be omitted.
Let's say that those two fields are Password and SSN.
This is when I receive an error if I don't specify a value for all the requiered fields, even thoug I set ISModified = false on those properties. Property(e =This seems like a really nice solution - no muss or fuss; you don't have to manually specify properties and it takes into account all of the OPs bullets - is there any reason this does not have more votes?