Here is my code:
Partial Public Class AppsEntities
Private Sub OnContextCreated()
AddHandler Me.SavingChanges, AddressOf context_SavingChanges
End Sub
Private Shared Sub context_SavingChanges(ByVal sender As Object, ByVal e As EventArgs)
For Each entry As ObjectStateEntry In DirectCast(sender, ObjectContext).ObjectStateManager.GetObjectStateEntries(EntityState.Modified)
If Not entry.IsRelationship And entry.Entity IsNot Nothing Then
For Each propName As String In entry.GetModifiedProperties()
Dim audit As New History
audit.action = "Changed information in " & propName & " to " & entry.CurrentValues(propName) & " from " & entry.OriginalValues(propName)
audit.action_by = "dmackey"
audit.action_date = Date.Now
audit.extension_id = entry.CurrentValues.GetValue(1)
Next
End If
Next
End Sub
End Class
How do I save this new object I've created? In LINQ I'd do something like:
datasource.object.insertonsubmit(audit)
datasource.SubmitChanges()