public async Task <IDataReader> ExecuteKustoQueryAsync(KustoQuery query) { var client = KustoQueryProvider; var properties = new ClientRequestProperties(); foreach (var parameter in query.Parameters) { properties.SetParameter(parameter.Name, parameter.Value.ToString()); } string text = query.Text; if (query.Parameters?.Any() == true) { string parameterList = String.Join(",", query.Parameters.Select(p => $"{p.Name}:{p.Type}")); text = $"declare query_parameters ({parameterList});{query.Text}"; } try { return(await client.ExecuteQueryAsync( DatabaseName, text, properties)); } catch (SemanticException) { return(null); } }
public async Task <T> GetSingleValueFromQueryAsync <T>(KustoQuery query) { var result = await ExecuteKustoQueryAsync(query); if (result.Read()) { var resultValue = result.GetValue(0); if (resultValue == System.DBNull.Value || resultValue == null) { return(default(T)); } else { return((T)resultValue); } } return(default(T)); }