Пример #1
0
        private DSPResource CreateDSPResource <TSource>(TSource document, string resourceName)
        {
            var typedDocument = document;
            var text          = JsonConvert.SerializeObject(typedDocument);
            var resource      = DocumentDbDSPConverter.CreateDSPResource(JObject.Parse(text), this.dbMetadata, resourceName);

            if (this.dbMetadata.Configuration.UpdateDynamically)
            {
                UpdateMetadataFromResourceSet(resourceName, JObject.Parse(text));
            }

            return(resource);
        }
        private void PopulateData(DSPInMemoryContext dspContext, DocumentDbContext dbContext)
        {
            foreach (var resourceSet in this.Metadata.ResourceSets)
            {
                var storage    = dspContext.GetResourceSetStorage(resourceSet.Name);
                var collection = dbContext.Database.GetCollection(resourceSet.Name);
                var query      = dbContext.Client.CreateDocumentQuery <JObject>(collection.DocumentsLink);
                foreach (var document in query)
                {
                    var resource = DocumentDbDSPConverter.CreateDSPResource(document, this.dbMetadata, resourceSet.Name);
                    storage.Add(resource);

                    if (this.dbMetadata.Configuration.UpdateDynamically)
                    {
                        UpdateMetadataFromResourceSet(dbContext, resourceSet, document);
                    }
                }
            }
        }