public static async Task<HashPartitionResolver> InitializeCustomHashResolver(Func<object, string> partitionKeyExtractor, DocumentClient client, Database database, string[] collectionNames)
{
// Set local to input.
string[] CollectionNames = collectionNames;
int numCollectionNames = CollectionNames.Length;
// Create array of DocumentCollections.
DocumentCollection[] collections = new DocumentCollection[numCollectionNames];
// Create string array of Self Links to Collections.
string[] selfLinks = new string[numCollectionNames];
//Create some collections to partition data.
for (int i = 0; i < numCollectionNames; i++)
{
collections[i] = await DocumentClientHelper.GetCollectionAsync(client, database, CollectionNames[i]);
selfLinks[i] = collections[i].SelfLink;
}
// Join Self Link Array into a comma separated string.
string selfLinkString = String.Join(", ", selfLinks);
var hashResolver = new HashPartitionResolver(
partitionKeyExtractor,
new[] { selfLinkString });
client.PartitionResolvers[database.SelfLink] = hashResolver;
return hashResolver;
}