-
Notifications
You must be signed in to change notification settings - Fork 16
Description
I have identified a slight shortcoming in the way that the merge operation is exposed in the library. The problem is that you are always forced to update each and every property of the record representation, which can be problematic in certain applications. For example, consider the record:
type Record = { [<PartitionKey>] : string; [<RowKey>] : string ; Value1 : int; Value2 : int }Supposing I only wanted to merge with respect to the second value, I would be have to be forced to fetch the original record, update the value in question, and then perform a full merge on the record properties.
As it is, the only way to overcome the problem is to create a second RecordPartial type that only contains the updated value in question, but I find this approach to be a bit problematic.
I've come up with the following idea. We could append the operation:
type Operation<'T> =
...
| MergePartial of Expr<'T -> 'T> * etag:string
...which could be used as follows:
MergePartial <@ fun record -> { record with Value2 = 42 } @>This would allow the library to build partial entities for merging in the expected way. Obviously it requires a bit of quotation manipulation to achieve this but in my experiments I've become convinced it is perfectly doable.