Ejemplo n.º 1
0
        public void Update(TDataType document)
        {
            TDataType oldData;

            if (!_data.TryGetValue(DataDocument.GetDocumentId(document), out oldData))
            {
                throw new InstanceNotFoundException();
            }

            if (DataDocument.HasEtag <TDataType>())
            {
                if (DataDocument.GetDocumentEtag(oldData) != DataDocument.GetDocumentEtag(document))
                {
                    throw new DBConcurrencyException();
                }
            }

            DataDocument.SetDocumentEtagNew(document);
            _data[DataDocument.GetDocumentId(document)] = document;
        }
Ejemplo n.º 2
0
        private static void InternalUpdate(TDataType document, IStructuredDataDictionary <TDataType> tbl)
        {
            var fetchedData = tbl.Fetch(new string[] { DataDocument.GetDocumentId(document) });

            if (!fetchedData.Any())
            {
                throw new InstanceNotFoundException();
            }


            var oldData = fetchedData.First().Data;
            var eTag    = fetchedData.First().ETag;

            if (DataDocument.HasEtag <TDataType>())
            {
                eTag = DataDocument.GetDocumentEtag(document);
                if (DataDocument.GetDocumentEtag(oldData) != eTag)
                {
                    throw new DBConcurrencyException();
                }
            }

            tbl.Update(DataDocument.GetDocumentId(document), document, eTag);
        }