Hi,
I am developing an application where I need to save an entity. Before I save, I need to check whether object is to be Updated or Inserted. Currently, I am using this method and it works.
Dim objEmpHistory As New EntityClasses.ApemploymentHistoryEntity
If objEmpHistory.FetchUsingPK(MyBase.Participant.ParticipantId, ItemNumber) = False Then
objEmpHistory.ParticipantId = MyBase.Participant.ParticipantId
objEmpHistory.ItemNumber = ItemNumber
End If
objEmpHistory.JobTitle = txtCurrentJobTitle.Text
objEmpHistory.Save()
ParticipantId and ItemNumber are key fields.
Is there a better way to check whether the record is present in database than this? Over here, when I do FetchUsingPK(), the returned object has the Primary key fields set, even if it is not present in database, so when I save, it gives an error unless I set them again with same value.
Thanks in advance.
Baiju Nagori