private static void AssertValidEtag(string key, Table.ReadResult doc, Table.ReadResult docInTx, Guid? etag)
{
if (doc == null)
return;
var existingEtag =
docInTx != null
? new Guid(docInTx.Key.Value<byte[]>("etag"))
: new Guid(doc.Key.Value<byte[]>("etag"));
if (etag != null && etag.Value != existingEtag)
{
throw new ConcurrencyException("PUT attempted on document '" + key +
"' using a non current etag")
{
ActualETag = existingEtag,
ExpectedETag = etag.Value
};
}
}