Hello,
I guess this is similar to the LLBLGen 2.5's auditing framework, but is there a way to do something simple in 2.0 (self-servicing)?
For one particular entity, whenever save is called I like to log a couple additional records.
I have currently put the code into the the OnSave function.
However, is there a way to submit the commands as part of a transaction so that they will go through ONLY if the entity was successfully comitted to the database?
This is what I have so far.
Protected Overrides Sub OnSave()
If Me.IsNew Then
Me.EntryDate = Now
End If
'Automatically set the update time
MyBase.UpdateTime = Now
'If the status field has been changed, we should also log a event model status record
If Me.Fields(EventModelFieldIndex.Status).IsChanged Then
Dim _EventModelStatus As New EventModelStatusEntity
With _EventModelStatus
.EventModelId = Me.EventModelId
.Status = Me.Status
.StatusTime = Now
End With
_EventModelStatus.Save()
End If
MyBase.OnSave()
End Sub
I just like to know what the best way is to do this - while maintain some sort of transactional integrity.
Thanks!