I have a update method in my data layer such this:
public clacc datalayerSec_User
private objUIData as new UIData
Public Function Update(ByVal objUser As SEC_USER) As Boolean
Try
objUIData.SEC_USERs.Attach(objUser)
objUIData.Refresh(RefreshMode.KeepCurrentValues, objUser)
objUIData.SubmitChanges(ConflictMode.ContinueOnConflict)
Return True
Catch ex As Exception
Throw ex
End Try
End Function
end class
And I write this code to update my data:
Dim tmpUser As New UI_Class.BAL.Security.cls_SEC_USER
Dim tblUser = tmpUser.GetAll.SingleOrDefault(Function(x) x.DS_OPENID = pOpenID)
tblUser.DT_LAST_LOGIN = DateTime.Now
tmpUser.Update(tblUser)
When I run it, I have this error message: Cannot attach an entity that already exists.
How can it be fixed?