本文整理汇总了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;
}
}
}
示例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);
}
示例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;
}
示例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);
}
}
}