At the moment to check for changes with my entity framework object, I check in the database and I go through each object and compare the properties with the updated, if they are updated then my date modified will be updated as well.
I find that it's getting very lengthy in code and was wondering if there's a cleaner way to check for changes using entity framework. I was thinking maybe using deepcopy with a object comparison and compare something like below. But I would have to set each of my tables to be serialized and I don't know if that's a good thing.
if (Equals(oldentity, newentity))
{
newentity.ModifiedDate = DateTime.Now
}
My current method of tracking changes
if (oldentity.firstname != newentity.firstname || oldentity.lastname != newentity.lastname)
{
newentity.ModifiedDate = DateTime.Now
}
The if statement is a snippet, my entity has many properties so it gets lengthy...