public async Task <int> DropIndexAsync(string label, string propertyname) { string query = $"DROP INDEX ON :{label}({propertyname})"; int count = 0; using (ISession session = this._driver.Session()) { try { await session.ReadTransactionAsync(async (tx) => { IStatementResultCursor reader = await tx.RunAsync(query); await reader.ConsumeAsync(); IResultSummary summary = await reader.SummaryAsync(); count = summary.Counters.IndexesRemoved; }); } catch (Exception e) { this._logger.LogError(e, $"Error dropping index for label {label} on property {propertyname}"); } finally { await session.CloseAsync(); } } return(count); }
public async Task <int> CreateIndexAsync(NewIndex newIndex) { string query = $"CREATE INDEX ON :{newIndex.Label}({newIndex.Property})"; int count = 0; using (ISession session = this._driver.Session()) { try { await session.ReadTransactionAsync(async (tx) => { IStatementResultCursor reader = await tx.RunAsync(query); await reader.ConsumeAsync(); IResultSummary summary = await reader.SummaryAsync(); count = summary.Counters.IndexesAdded; }); } catch (Exception e) { this._logger.LogError(e, $"Error creating index for label {newIndex.Label} on property {newIndex.Property}"); } finally { await session.CloseAsync(); } } return(count); }
/// <summary> /// Read each record in the result stream and apply the operation on each record. /// </summary> /// <param name="result">The result stream.</param> /// <param name="operation">The operation is carried out on each record.</param> /// <returns>The result summary after all records have been processed.</returns> public static async Task <IResultSummary> ForEachAsync(this IStatementResultCursor result, Action <IRecord> operation) { Throw.ArgumentNullException.IfNull(result, nameof(result)); while (await result.FetchAsync().ConfigureAwait(false)) { var record = result.Current; operation(record); } return(await result.SummaryAsync().ConfigureAwait(false)); }
private async Task DiscardUnconsumedAsync() { if (_result != null) { IStatementResultCursor cursor = null; try { cursor = await _result.ConfigureAwait(false); } catch (Exception) { // ignored if the cursor failed to create } if (cursor != null) { await cursor.SummaryAsync().ConfigureAwait(false); } } }
private async Task DiscardUnconsumed() { foreach (var result in _results) { IStatementResultCursor cursor = null; try { cursor = await result.ConfigureAwait(false); } catch (Exception) { // ignore if cursor failed to create } if (cursor != null) { await cursor.SummaryAsync().ConfigureAwait(false); } } }
public IResultSummary Summary() { return(_executor.RunSync(() => _cursor.SummaryAsync())); }