public async Task <IList <T> > Query([NotNull] string query, CancellationToken cancellationToken) { logger.LogInformation($"Executing kusto query: {query}"); var watch = Stopwatch.StartNew(); var items = await kustoClient.ExecuteQuery <T>(query, TimeSpan.FromMinutes(30), cancellationToken); var list = items.ToList(); watch.Stop(); logger.LogInformation($"it took {watch.Elapsed} to retrieve {list.Count} records"); return(list); }
private async Task <int> ExecuteQuery(string query, SyncSettings syncSettings, CancellationToken cancellationToken) { _logger.LogInformation($"running kusto query: \n{query}\n"); int totalIngested = 0; var modelType = typeof(SyncSettings).Assembly.GetTypes() .FirstOrDefault(t => t.Name.Equals(syncSettings.Model)); if (modelType == null) { throw new InvalidOperationException($"Failed to find model: {syncSettings.Model}"); } _logger.LogInformation($"synchronizing {syncSettings.Model}"); await _kustoClient.ExecuteQuery(modelType, query, async (list) => { if (list?.Any() == true) { var totalAdded = await Ingest(list); totalIngested += totalAdded; _logger.LogInformation($"{nameof(PowerDevice)}: total of {list.Count} raw events found, {totalAdded} mapped device events added"); } }, cancellationToken); return(totalIngested); }