Пример #1
0
        public DocumentRow DocumentToRow <T>(T document)
        {
            string           content  = JsonConvert.SerializeObject(document);
            DocumentMetadata metadata = CreateMetaData(document);

            return(new DocumentRow(content, metadata));
        }
Пример #2
0
        public void FillDocument <T>(T document, DocumentMetadata metadata)
        {
            DocumentConfiguration <T> configuration = GetConfiguration <T>();

            if (configuration != null)
            {
                if (configuration.Id != null)
                {
                    Reflect <T> .GetProperty(configuration.Id).SetValue(document, metadata.Id);
                }
                if (configuration.Key != null)
                {
                    Reflect <T> .GetProperty(configuration.Key).SetValue(document, metadata.Key);
                }
                if (configuration.Index != null)
                {
                    Reflect <T> .GetProperty(configuration.Index).SetValue(document, metadata.Index);
                }
                if (configuration.Timestamp != null)
                {
                    Reflect <T> .GetProperty(configuration.Timestamp).SetValue(document, metadata.Timestamp);
                }
            }
        }
Пример #3
0
        public async Task SaveAsync <T>(T document, CancellationToken cancellationToken)
        {
            DocumentMetadata metadata = await _transaction.SaveAsync(_mapper.DocumentToRow(document), cancellationToken);

            _mapper.FillDocument(document, metadata);
        }