public List <T> Complete <T>()
        {
            var results = new List <T>(_result.Results.Length);

            for (var i = 0; i < _result.Results.Length; i++)
            {
                var document = (BlittableJsonReaderObject)_result.Results[i];
                var metadata = document.GetMetadata();
                var id       = metadata.GetId();
                var entity   = (T)_session.ConvertToEntity(typeof(T), id, document);
                results.Add(entity);

                var changeVector = BlittableJsonExtensions.GetChangeVector(metadata);
                _session.DocumentsByEntity[entity] = new DocumentInfo
                {
                    Id           = id,
                    ChangeVector = changeVector,
                    Document     = document,
                    Metadata     = metadata,
                    Entity       = entity
                };
            }

            return(results);
        }
Exemple #2
0
            private StreamResult <T> CreateStreamResult(BlittableJsonReaderObject json)
            {
                var metadata     = json.GetMetadata();
                var changeVector = BlittableJsonExtensions.GetChangeVector(metadata);
                var id           = metadata.GetId();

                json = _parent.Context.ReadObject(json, id);
                var entity = QueryOperation.Deserialize <T>(id, json, metadata, _projectionFields, true, _parent);

                var streamResult = new StreamResult <T>
                {
                    ChangeVector = changeVector,
                    Id           = id,
                    Document     = entity,
                    Metadata     = new MetadataAsDictionary(metadata)
                };

                return(streamResult);
            }
Exemple #3
0
        public async Task load_with_big_key_returns_metadata_async()
        {
            using (var store = GetDocumentStore())
            {
                var index = new Customers_ByName();
                index.Execute(store);
                var id = new string('a', 130);

                using (var session = store.OpenSession())
                {
                    session.Store(new Customer {
                        Name = "John", Address = "Tel Aviv"
                    }, id);
                    session.SaveChanges();
                }

                WaitForIndexing(store);

                using (var commands = store.Commands())
                {
                    var customer = await commands.GetAsync("customers/1");

                    Assert.NotNull(customer);

                    var metadata = customer.BlittableJson.GetMetadata();
                    var key      = metadata.GetId();
                    Assert.NotNull(key);

                    dynamic customerDynamic = customer;

                    Assert.Equal(customerDynamic.Name.ToString(), "John");
                    Assert.Equal(customerDynamic.Address.ToString(), "Tel Aviv");

                    Assert.NotNull(BlittableJsonExtensions.GetChangeVector(metadata));
                    Assert.NotNull(metadata.GetLastModified());

                    object _;
                    Assert.NotNull(metadata.TryGetMember(Constants.Documents.Metadata.RavenClrType, out _));
                    Assert.NotNull(metadata.TryGetMember(Constants.Documents.Metadata.Collection, out _));
                    Assert.NotNull(metadata.TryGetMember(Constants.Documents.Metadata.LastModified, out _));
                }
            }
        }
Exemple #4
0
        private StreamResult <T> CreateStreamResult <T>(BlittableJsonReaderObject json, string[] projectionFields)
        {
            var metadata     = json.GetMetadata();
            var changeVector = BlittableJsonExtensions.GetChangeVector(metadata);
            var id           = metadata.GetId();

            //TODO - Investigate why ConvertToEntity fails if we don't call ReadObject before
            json = Context.ReadObject(json, id);
            var entity = QueryOperation.Deserialize <T>(id, json, metadata, projectionFields, true, this);

            var streamResult = new StreamResult <T>
            {
                ChangeVector = changeVector,
                Id           = id,
                Document     = entity,
                Metadata     = new MetadataAsDictionary(metadata)
            };

            return(streamResult);
        }
            private StreamResult <T> CreateStreamResult(BlittableJsonReaderObject json)
            {
                var    metadata     = json.GetMetadata();
                var    changeVector = BlittableJsonExtensions.GetChangeVector(metadata);
                string id;

                //MapReduce indexes return reduce results that don't have @id property
                metadata.TryGetId(out id);

                json = _parent.Context.ReadObject(json, id);
                var entity = QueryOperation.Deserialize <T>(id, json, metadata, _projectionFields, true, _parent);

                var streamResult = new StreamResult <T>
                {
                    ChangeVector = changeVector,
                    Id           = id,
                    Document     = entity,
                    Metadata     = new MetadataAsDictionary(metadata)
                };

                return(streamResult);
            }