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); }
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)); }
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)); }