Microsoft Poor Documentation on Azure: Table​Operation.​Merge Method

126 views Asked by At

I am a newbie in Azure so I read the Microsoft Table​Operation.​Merge Method.

Creates a new table operation that merges the contents of the given entity with the existing entity in a table.

That is all... Now, what should I understand from the "merge" concept? How exactly this Merge happens.

Say I have

Body {PK: b, RK: 1, LeftHand: null, RightHand: 1000, LeftLeg: ll} >
Body {PK: b, RK: 1, LeftHand: 9999, RightHand: null, Head: h}
  • What happens with empty/null values?
  • What happens if the item is not found?
  • What kind of exceptions should I expect?
  • What is the difference between InsertOrMerge and Merge?

How can I guess ?

1

There are 1 answers

15
Gaurav Mantri On BEST ANSWER

Merge operation actually creates a superset. To put it simply:

  • If old entity doesn't have an attribute and the new one does: The resulting entity will have that new attribute.
  • If old entity has an attribute and the new one does not: That attribute's value will not be changed. It will be the same as that of the old value.
  • If old entity has an attribute and the new one also has that attribute: The resulting entity will replace the attribute value.

So in your example:

Old Entity:

{PK: b, RK: 1, LeftHand: null, RightHand: 1000, LeftLeg: ll}

New Entity:

{PK: b, RK: 1, LeftHand: 9999, RightHand: null, Head: h}

Entity After Merge Operation:

{PK: b, RK: 1, LeftHand: 9999, RightHand: 1000, LeftLeg: 11, Head: h}