/// <summary> /// Executes the index creation against the specified document store. /// </summary> public virtual async Task ExecuteAsync(IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention documentConvention, CancellationToken token = default(CancellationToken)) { Conventions = documentConvention; var indexDefinition = CreateIndexDefinition(); #if !DNXCORE50 if (documentConvention.PrettifyGeneratedLinqExpressions) { var serverDef = await asyncDatabaseCommands.GetIndexAsync(IndexName, token).ConfigureAwait(false); if (serverDef != null && CurrentOrLegacyIndexDefinitionEquals(documentConvention, serverDef, indexDefinition)) { await AfterExecuteAsync(asyncDatabaseCommands, documentConvention, token).ConfigureAwait(false); return; } } #endif // This code take advantage on the fact that RavenDB will turn an index PUT // to a noop of the index already exists and the stored definition matches // the new definition. await asyncDatabaseCommands.PutIndexAsync(IndexName, indexDefinition, true, token).ConfigureAwait(false); if (Priority != null) { await asyncDatabaseCommands.SetIndexPriorityAsync(IndexName, Priority.Value, token).ConfigureAwait(false); } await AfterExecuteAsync(asyncDatabaseCommands, documentConvention, token).ConfigureAwait(false); }
/// <summary> /// Executes the index creation against the specified document store. /// </summary> public virtual async Task ExecuteAsync(IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention documentConvention, CancellationToken token = default(CancellationToken)) { Conventions = documentConvention; var indexDefinition = CreateIndexDefinition(); if (documentConvention.PrettifyGeneratedLinqExpressions) { var serverDef = await asyncDatabaseCommands.GetIndexAsync(IndexName, token); if (serverDef != null && CurrentOrLegacyIndexDefinitionEquals(documentConvention, serverDef, indexDefinition)) { return; } } // This code take advantage on the fact that RavenDB will turn an index PUT // to a noop of the index already exists and the stored definition matches // the new definition. await asyncDatabaseCommands.PutIndexAsync(IndexName, indexDefinition, true, token); if (Priority != null) { await asyncDatabaseCommands.SetIndexPriorityAsync(IndexName, Priority.Value, token); } if (Conventions.IndexAndTransformerReplicationMode.HasFlag(IndexAndTransformerReplicationMode.Indexes)) { await ReplicateIndexesIfNeededAsync(asyncDatabaseCommands); } }