当前位置: 首页>>代码示例>>C#>>正文


C# DocumentClient.ReadDocumentCollectionAsync方法代码示例

本文整理汇总了C#中Microsoft.Azure.Documents.Client.DocumentClient.ReadDocumentCollectionAsync方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentClient.ReadDocumentCollectionAsync方法的具体用法?C# DocumentClient.ReadDocumentCollectionAsync怎么用?C# DocumentClient.ReadDocumentCollectionAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Azure.Documents.Client.DocumentClient的用法示例。


在下文中一共展示了DocumentClient.ReadDocumentCollectionAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDocumentCollection

        private static void CreateDocumentCollection(DocumentClient documentClient)
        {
            // Create the database if it doesn't exist.

            try
            {
                documentClient.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri(DatabaseName, CollectionName))
                    .GetAwaiter()
                    .GetResult();
            }
            catch (DocumentClientException de)
            {
                // If the document collection does not exist, create it
                if (de.StatusCode == HttpStatusCode.NotFound)
                {
                    var collectionInfo = new DocumentCollection
                    {
                        Id = CollectionName,
                        IndexingPolicy = new IndexingPolicy(new RangeIndex(DataType.String) { Precision = -1 })
                    };

                    documentClient.CreateDocumentCollectionAsync(
                        UriFactory.CreateDatabaseUri(DatabaseName),
                        collectionInfo,
                        new RequestOptions { OfferThroughput = 400 }).GetAwaiter().GetResult();
                }
                else
                {
                    throw;
                }
            }
        }
开发者ID:XpiritBV,项目名称:mini-hacks,代码行数:32,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            DocumentClient client = new DocumentClient(new Uri(endpointUrl), authorizationKey);
            DocumentCollection collection = client.ReadDocumentCollectionAsync(documentCollectionLink).Result;

            Point point = new Point(-87.636836, 41.884615);
            int minDistance = 100;
            int maxDistance = 5000;
            int maxPoints = 500;

            IEnumerable<dynamic> points = SpatialHelper.Near(client, collection.DocumentsLink, propertyName, point, minDistance, maxDistance, maxPoints);

            long count = 0;
            foreach(dynamic p in points)
            {
                Console.WriteLine(@"Point ID: {0}", p.id);
                ++count;
            }

            Console.WriteLine(@"Found {0} points", count);
        }
开发者ID:rnagpal,项目名称:azure-documentdb-net,代码行数:21,代码来源:Program.cs

示例3: CheckSize

        private static async Task<bool> CheckSize(DocumentCollection dc, DocumentClient client)
        {
            double backRate = (double) 2/100000;
            var res = await client.ReadDocumentCollectionAsync(dc.SelfLink);
            var size = res.CollectionSizeUsage;
            var totalSize = res.CollectionSizeQuota;

            return size > totalSize*backRate;
        }
开发者ID:tzkwizard,项目名称:Azure,代码行数:9,代码来源:LoadBalance.cs

示例4: UpdateDc

        private static async Task UpdateDc(DocumentCollection oldDc, DocumentClient client,
            Database database, DocumentCollection origin)
        {
            var res = await client.ReadDocumentCollectionAsync(oldDc.SelfLink);
            var size = res.CollectionSizeUsage;
            var totalSize = res.CollectionSizeQuota;
            if (size > totalSize*2/100000)
            {
                var ds =
                    from d in client.CreateDocumentQuery<PostMessage>(oldDc.DocumentsLink)
                    where d.Type == "Post"
                    select d;

                Hashtable hs = new Hashtable();
                var n = ds.ToList().Count;
                foreach (var d in ds)
                {
                    if (!hs.ContainsKey(d.Path.District))
                    {
                        hs.Add(d.Path.District, 1);
                    }
                    else
                    {
                        hs[d.Path.District] = (int) hs[d.Path.District] + 1;
                    }
                }
                Hashtable newList = new Hashtable();
                Hashtable oldList = new Hashtable();

                foreach (DictionaryEntry h in hs)
                {
                    var c = 0;
                    foreach (DictionaryEntry hh in newList)
                    {
                        c = c + (int) hh.Value;
                    }
                    if (c < n*0.45 && (c + (int) h.Value < n*0.55))
                    {
                        newList.Add(h.Key, h.Value);
                    }
                    else
                    {
                        oldList.Add(h.Key, h.Value);
                    }
                }


                if (newList.Count > 0)
                {
                    //create new collection
                    /*var t = (long) (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds;
                  DocumentCollection newDc=await client.CreateDocumentCollectionAsync(database.CollectionsLink,
                                                        new DocumentCollection
                                                        {
                                                            Id = "LMSCollection"+t
                                                        });*/

                    //search collection
                    DocumentCollection newDc = client.CreateDocumentCollectionQuery(database.SelfLink)
                        .Where(c => c.Id == "LMSCollection1444075919174")
                        .AsEnumerable()
                        .FirstOrDefault();

                    await SaveDisList(newList, oldList, origin, oldDc, newDc, client);

                    await TransferDc(oldDc, newDc, client, database, newList);
                }
            }
        }
开发者ID:tzkwizard,项目名称:ELS,代码行数:69,代码来源:Dichotomy.cs


注:本文中的Microsoft.Azure.Documents.Client.DocumentClient.ReadDocumentCollectionAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。