Exemplo n.º 1
0
        private async Task CompareReadVsQuery()
        {
            await client.OpenAsync().ConfigureAwait(false);

            var random = new Random((int)DateTime.Now.Ticks);
            var doc    = new SampleDocument
            {
                Id     = Guid.NewGuid().ToString(),
                prop1  = Guid.NewGuid().ToString(),
                prop2  = random.Next(100),
                prop3  = Guid.NewGuid().ToString(),
                prop4  = random.Next(100),
                prop5  = DateTime.UtcNow.ToLongTimeString(),
                prop6  = random.Next(100),
                prop7  = Guid.NewGuid().ToString(),
                prop8  = random.Next(100),
                prop9  = Guid.NewGuid().ToString(),
                prop10 = random.Next(100),
                prop11 = Guid.NewGuid().ToString(),
                prop12 = random.Next(100),
                prop13 = Guid.NewGuid().ToString(),
                prop14 = random.Next(100),
                prop15 = Guid.NewGuid().ToString(),
                prop16 = random.Next(100)
            };

            await this.CreateSampleDocument(database, collection, doc);

            double readRU = await this.ReadSampleDocument(doc.Id);

            Console.WriteLine("Read cost: {0} RU", readRU);

            double queryRU = await this.QuerySampleDocument(doc.Id);

            Console.WriteLine("Query cost: {0} RU", queryRU);


            double queryRangeRU = await this.QuerySampleDocumentByRange(doc.Id);

            Console.WriteLine("Range Query cost: {0} RU", queryRangeRU);
        }
Exemplo n.º 2
0
        private async Task <double> CreateSampleDocument(string databaseName, string collectionName, SampleDocument sample)
        {
            var result = await client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), sample);

            return(result.RequestCharge);
        }