Rodrigo Catarino wrote:
Hi Rodrigo , sorry but i am not able to understand, that the advantage to us the advancedquery to update the data.
Rajendra koranga wrote:
Hi,
The simple update doesn't allow to have another variable in the where clause, so in order to do that I use an advancequery like mentioned earlier by Greg
Update table set Somecolumn = @NewValue, LastUpdateDateTime = @CurrentDateTime where Id = @RowId and LastUpdateDateTime = @OriginalDateTime from row when read.
Apart from this issue, it's good practise to use the encapsulation as described by J. for the CRUD-actions of entities. It's also convenient to set the CreatedOn/-By and UpdatedOn/-By values there.
For this specific case you can compare the record you want to save ('Balance') with the record in te database, which you get using GetForUpdate. The you can compare the ModifiedOn dates of both records. If these differ, you can let the action fail and provide feedback to the user that the record has been changed in the meantime.