How to find all values that have changes in mvc object

‘Compare the original and new versions of any db model, return a string of changes
    Function GetChanges(ByRef database As YourCaretakerEntitiesByRef originalValues As ObjectByRef newValues As ObjectAs String
        Dim returnString As New StringBuilder()
        Dim comparer As ObjectStateEntry = database.ObjectStateManager.GetObjectStateEntry(originalValues)
        For Each changedField In comparer.GetModifiedProperties()
            returnString.Append(” changed from “)
            returnString.Append(” to “)
            returnString.Append(“, “)
        If returnString.Length > 0 Then returnString = returnString.Replace(“, ““.”, returnString.Length – 2, 2)
        Return returnString.ToString()
    End Function

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: