c# - unable to handle Amazon.DynamoDBv2.Model.ConditionalCheckFailedException -
when execute following code amazon.dynamodbv2.model.conditionalcheckfailedexception not catching.
button click
public delegatecommand savecommand { { _savecommand = new delegatecommand(async (arg) => { await this.savecommandexecuted(arg); }, this.savecommandcanexecute); return _savecommand; } set { _savecommand = value; onpropertychanged("savecommand"); } }
save method content
public async task savecommandexecuted(object parameter) { try { await patientdatasource.instance.savepatient(patient); } catch (amazon.dynamodbv2.model.conditionalcheckfailedexception ex) { exception = ex.message; } }
database operation method
public async task savepatient(patient patient) { var context = commonutils.instance.dynamodbcontext; try { patient.patientid = 1; await context.saveasync<patient>(patient); } catch(amazon.dynamodbv2.model.conditionalcheckfailedexception ex) { throw ex; } }
can please advice.
dynamodbcontext (the equivalent of dynamodbmapper in .net sdk) conditions on version attribute of orm object, in your case, patient class, , on else in dynamodboperationconfig. fact unable catch conditionalcheckfailedexception suggests not have concurrent writes happening on same patient. please see this post details.
Comments
Post a Comment