protected List <dynamic> RunAtomicQueryWithKqlNode(dynamic eventDynamic, string query) { var result = new List <dynamic>(); KqlNode node = new KqlNode(); node.AddKqlQuery(new KqlQuery { Comment = "TestQuery", Query = query }); // Subscribe to the sucessful detections. node.Subscribe(evt => { result.Add(evt.Output); }); // Add the detections. node.OnNext((IDictionary <string, object>)eventDynamic); return(result); }
private static bool Test( string kql, Func <IEnumerable <StockQuote>, IEnumerable <Summary> > linq, StockQuote[] quotes) { KqlNode node = new KqlNode(); node.AddKqlQuery(new KqlQuery { Comment = "Blank Comment", Query = kql }); Console.WriteLine(kql); Console.WriteLine(); var linqResult = linq(quotes) .Select(a => string.Format("{0} {1} {2}", a.Time, a.Symbol, a.Result)) .ToArray(); List <string> kqlResult = new List <string>(); var obs = quotes.ToObservable() .ToDynamic(e => e); KqlNode kqlNode = new KqlNode(); List <KqlQuery> kustoQueryUserInput = new List <KqlQuery> { new KqlQuery { Comment = "Blank Comment", Query = kql.Trim() } }; kqlNode.AddKqlQueryList(kustoQueryUserInput, true); ManualResetEvent completedEvent = new ManualResetEvent(false); kqlNode.Subscribe(evt => { kqlResult.Add(string.Format("{0} {1} {2}", ((DateTime)evt.Output["Time"]), evt.Output["Symbol"], evt.Output["r"])); }, () => { completedEvent.Set(); }); using (obs.Subscribe(kqlNode)) { completedEvent.WaitOne(); kqlNode.OnCompleted(); } Console.WriteLine(" LINQ Rx.KQL"); for (int i = 0; i < linqResult.Length; i++) { Console.WriteLine("{0}\t{1}", linqResult[i], kqlResult[i]); } return(linqResult.Length == kqlResult.Count); }