What's the recommended way of updating an entity? So far, I figured out two ways:
- Just create a new entity with the existing Id and updated property values, and use session.SaveOrUpdate()
- Use a DTO, retrieve the existing entity using session.Load(dto.Id), assign new vaues from the dto, then save.
No1 requires much less effort, but sometimes I'm getting an exception: "a different object with the same identifier value was already associated with the session". Is there a simple way around that?
No2 might require an extra trip to the DB I guess?
Sorry if that's been answered already, just couldn't find the answer.
Thanks ulu