DynamoDBContext with conditional update

梦想的初衷 提交于 2019-12-11 10:41:16

问题


in my application i'm using amazon object persistence model and use DynamoDBContext for operations(CURD and execute queries). i need to know that how can i use conditional update using DynamoDBContext. and it should be asynchronous.

I know the way of doing it using amazon low-level API.

my application is developed using C# Dot Net(4.5) thank you.


回答1:


.NET Async DynamoDBContext.Save call uses SaveHelper. SaveHelper calls UpdateHelper with an operationConfig. As DynamoDBOperationConfig has a ConditionalOperator field, you may try using that to condition puts/updates on attribute values. Note that you can only enforce conditions on one item in this call. If you do that, you will not be able to overwrite an item that already exists, thereby enforcing uniqueness. I suggest you use a UUID instead of an incrementing number for your hash key though. While atomic counters are supported in the context of one item, they are not supported across all the items of a table. For conditional writes not supported by the DynamoDBContext.Save call, you can always use the low-level API with a condition expression to perform your conditional write.



来源:https://stackoverflow.com/questions/31066280/dynamodbcontext-with-conditional-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!