コード例 #1
0
        private UnversionedDbDocument CreateDbDocument <TDocument>(
            TDocument document,
            string documentId,
            DocumentTypeMapping <TDocument> mapping,
            OperationOptions operationOptions,
            DateTime createdTime,
            DateTime modifiedTime)
        {
            var dbRecord = new UnversionedDbDocument();

            dbRecord.Id           = CreateDbRecordId(mapping, documentId);
            dbRecord.DocumentId   = documentId;
            dbRecord.Service      = DbAccess.ConfigManager.ServiceName;
            dbRecord.PartitionKey = mapping.PartitionKeyMapper(document);
            dbRecord.Actor        = GetActorId();

            dbRecord.CreatedTimestamp = createdTime;
            dbRecord.Timestamp        = modifiedTime;

            if (operationOptions.Ttl.HasValue)
            {
                dbRecord.TimeToLive = operationOptions.Ttl.Value;
            }

            SetDocumentContent(dbRecord, document, mapping);

            return(dbRecord);
        }
コード例 #2
0
        private DocumentWithMetadata <TDocument> ReadDocumentWithMetadata <TDocument>(
            DocumentTypeMapping <TDocument> mapping,
            UnversionedDbDocument document)
        {
            var metadata = new DocumentMetadata(document.CreatedTimestamp, document.Timestamp, document.Actor);

            TDocument content;

            if (!TryGetDocumentContent(document, mapping, out content, out _))
            {
                return(null);
            }

            return(new DocumentWithMetadata <TDocument>(metadata, content));
        }
コード例 #3
0
        private DocumentReadResult <TDocument> ReadDocument <TDocument>(
            DocumentTypeMapping <TDocument> mapping,
            UnversionedDbDocument document)
        {
            var metadata = new DocumentMetadata(document.CreatedTimestamp, document.Timestamp, document.Actor);

            TDocument content;
            DocumentReadFailureDetails failure;

            if (!TryGetDocumentContent(document, mapping, out content, out failure))
            {
                return(DocumentReadResult <TDocument> .CreateFailure(document.DocumentId, metadata, failure));
            }

            return(DocumentReadResult <TDocument> .CreateOkay(document.DocumentId, metadata, content));
        }