static void Main()
{
var queryOutput = Query.Run ("myquery.linq");
if (queryOutput.Successful)
File.WriteAllText ("results.html", queryOutput.Results);
}
Here's what the complete automation interface might look like:
{
// All members threadsafe
public class Query : IDisposable
{
// args would be for queries of type "C# Program"
// or "VB Program" and would get passed to the Main method.
public Query (string fileToOpen,
params object[] optionalArgs) { }
public ResultsFormat ResultsFormat { get; set; }
public void Start () { }
public void Start (bool waitUntilComplete) { }
public bool IsExecuting { get; }
public void Cancel () { }
public WaitHandle WaitHandle { get; }
public QueryOutput Output { get; }
public void Dispose () { }
// Helper method
public static QueryOutput Run (string filePath)
{
using (var query = new Query (filePath))
{
query.Start (true);
return query.Output;
}
}
}
public enum ResultsFormat
{
// Default - identical to LINQPad's standard output
Xhtml,
// No fluff - ideal for regression testing
Text,
// This would be effective for queries that dumped
// a single result set.
CSV
}
public class QueryOutput
{
public readonly bool Successful;
public readonly string Results;
public readonly string SqlTranslation;
public readonly string LambdaTranslation;
public readonly string ILTranslation;
}
}
Command-line support would build on this, although it would expose only a small subset of the features available via the automation interface.
It would also be possible to automate LINQPad from within LINQPad itself - so you could run several queries in one go.
What are people's thoughts?
Joe














