コード例 #1
0
        public async Task <InventoryItem> PutInventoryItem(InventoryItem item)
        {
            //Grab a link to the collection
            var collection = await DocumentDbUtil.GetOrCreateCollectionAsync(this.dbClient, this.docDb, this.dbSettings.CollectionId);

            //Store the new document
            var result = await this.dbClient.CreateDocumentAsync(collection.SelfLink, item);

            return((InventoryItem)(dynamic)result.Resource);
        }
コード例 #2
0
        public async Task <InventoryItem> PutInventoryItemWithHack(InventoryItem item)
        {
            //Grab a link to the collection
            var collection = await DocumentDbUtil.GetOrCreateCollectionAsync(this.dbClient, this.docDb, this.dbSettings.CollectionId);

            //Apply a Hacky fix - the regular metod loses it's Concrete properties
            //Running it manually through the serializer at this point seems to "fix" it
            ExpandoObject toStore = JsonConvert.DeserializeObject <ExpandoObject>(JsonConvert.SerializeObject(item));

            var result = await this.dbClient.CreateDocumentAsync(collection.SelfLink, toStore);

            return((InventoryItem)(dynamic)result.Resource);
        }