private List<string> GetCollections(
DocumentClient client,
Database database,
string collectionIdPrefix,
DocumentCollectionSpec spec)
{
var collections = new Dictionary<int, string>();
foreach (DocumentCollection collection in client.ReadDocumentCollectionFeedAsync(database.SelfLink).Result)
{
if (collection.Id.StartsWith(collectionIdPrefix))
{
int collectionNumber = int.Parse(collection.Id.Replace(collectionIdPrefix, string.Empty));
collections[collectionNumber] = collection.SelfLink;
}
}
if (collections.Any())
{
NextCollectionNumber = collections.Keys.Max() + 1;
}
else
{
NextCollectionNumber = 0;
}
// Return selflinks in ID order
return collections.OrderBy(kvp => kvp.Key).Select(kvp => kvp.Value).ToList();
}