I am trying to call LinqPad query from C#. Unfortunately, the code below does not work; the result is null as if nothing got returned by the script. I don't see any example of how to do this online. Any direction would be appreciated.
This is the LinqPad code for the query. It is saved as a C# Statement:
string Main(string message) { "testing".Dump(); return message.ToUpper(); } This is the code in C# code in a Visual Studio Project Console Application that attempts to call the query:
using System; using LINQPad; namespace ConsoleAppLinqPad { internal class Program { static void Main(string[] args) { string pathToQuery = @"C:\Users\synct\OneDrive\Documents\LINQPad Queries\"; string script = "samplequery.linq"; var wholePath = pathToQuery + script; using (var query = Util.Compile(wholePath)) { var results = query.Run(QueryResultFormat.Text, "hello world").ReturnValueAsync.GetAwaiter(); while (!results.IsCompleted) ; var result = results.GetResult(); Console.WriteLine(result.Dump()); // prints "HELLO WORLD?" } Console.ReadKey(); } } }