AngularAzureSearch.WebAPI.Initializers.PartitionInitializers.InitializeHashResolver C# (CSharp) Метод

InitializeHashResolver() публичный статический Метод

Initialize a HashPartitionResolver.
public static InitializeHashResolver ( string partitionKeyPropertyName, Microsoft.Azure.Documents.Client.DocumentClient client, Microsoft.Azure.Documents.Database database, string collectionNames ) : Task
partitionKeyPropertyName string The property name to be used as the partition Key.
client Microsoft.Azure.Documents.Client.DocumentClient The DocumentDB client instance to use.
database Microsoft.Azure.Documents.Database The database to run the samples on.
collectionNames string The names of collections used.
Результат Task
        public static async Task<HashPartitionResolver> InitializeHashResolver(string partitionKeyPropertyName, 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);

            //Initialize a partition resolver that users hashing, and register with DocumentClient. 
            //Uses User Id for PartitionKeyPropertyName, could also be TenantId, or any other variable.
            HashPartitionResolver hashResolver = new HashPartitionResolver(partitionKeyPropertyName, new[] { selfLinkString });
            client.PartitionResolvers[database.SelfLink] = hashResolver;

            return hashResolver;
        }