O'Reilly Forums: Linqpad Automation Interface - What Are Your Thoughts? - O'Reilly Forums

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Linqpad Automation Interface - What Are Your Thoughts? Rate Topic: -----

#1 User is offline   JoeAlbahari 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 529
  • Joined: 15-February 08
  • Gender:Male
  • Location:Perth, Australia

Posted 20 March 2009 - 11:28 PM

I'm thinking of adding an automation interface for LINQPad. This would mean you could reference LINQPad.exe from an external program and then automate the execution of queries like this:

CODE
using LINQPad.Automation;

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:

CODE
namespace Automation
{
    // 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

0

#2 User is offline   Terry Aney 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 19
  • Joined: 25-March 08

Posted 23 March 2009 - 06:46 AM

I think this sounds great. LINQPad has definately become my primary tool for doing almost anything. I almost feeling like I'm too addicted to it and becoming too much of a C# 'script junkie'...but I digress.

I also like the idea of LINQPad automating itself as well...it opens the possibilities of working on multiple databases from one 'master' script which I've needed a couple times.

My only suggestions are for the 'results' (and I'm not sure of the effort or feasiiblity)

1) I think there should be a pure Xml result.
2) Any chance of getting a IEnumerable<object> or similar passed back?

Both of these would be better suited if you needed to pass some information from script to script. Obviously with #2 we'd need to write an extension method or something, and speed wouldn't be great (thinking it'd need a bit of reflection), but that would be acceptable in the few situations where I'd like to pass info between scripts i.e. just getting some read only lists from one DB to another to compare and report on (if speed were issue, I'd just have to write a full blown c# app).

Finally, a bit off topic, but not sure if some of the re-work/effort you need for automation would be good time to think about it...it'd be nice in the output window of LINQPad if we could disable HTML encoding. There are a few times when I query stuff and want to make HTML links that are simply clickable from output window to open a new browser and navigate to my target. Would be great to get this too smile.gif

Looking forward to the automation with or without my result suggestions, I've a few good uses for just plain old single script automation 'right now' smile.gif
0

#3 User is offline   JoeAlbahari 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 529
  • Joined: 15-February 08
  • Gender:Male
  • Location:Perth, Australia

Posted 24 March 2009 - 04:36 AM

These are good ideas. Piping results between queries as objects might be tricky, though - the data would have to be serializable for a start. I'll think on it more.

Thanks

Joe

0

#4 User is offline   frankkampas 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 13-January 09

Posted 26 March 2009 - 06:39 AM

I think that automation would be very useful. I often call .NET code from other languages such as Mathematica. It would be a lot faster to set up C# code in LINQPad as opposed to Visual Studio.
0

#5 User is offline   shlomiw 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 04-May 09

Posted 04 May 2009 - 02:03 AM

Hi Joe,
I was looking for a way to integrate LINQPad queries results as a quick reports generator, leveraging the html output, on my admin site.

This Linqpad Automation Interface can really suit these needs.

Hope it'll be released soon,
Thanks,
Shlomi
0

#6 User is offline   ifwdev 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 13-January 09

Posted 06 May 2009 - 12:33 PM

Please please please blink.gif
0

#7 User is offline   JoeAlbahari 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 529
  • Joined: 15-February 08
  • Gender:Male
  • Location:Perth, Australia

Posted 14 May 2009 - 01:34 AM

You can now vote on this feature on UserVoice

Joe

This post has been edited by JoeAlbahari: 14 May 2009 - 01:35 AM

0

#8 User is offline   mschwab 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 15-May 09

Posted 15 May 2009 - 09:04 AM

Yes, please build the automation interface. Almost daily I think to myself "LinqPad really needs a Build button". It would be so nice to be able to hand an exe that does what my LinqPad script does over to less developer-minded people I work with. It seems with the automation interface that would be such a trivial task.

Thanks for the work you do on this!
0

#9 User is offline   RossHale 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 18-May 09

Posted 18 May 2009 - 12:09 PM

Hi Joe,

Like frankkampas, I call .NET code and objects from other languages. In my case Dyalog APL.
While manipulating the EDM graph of .NET objects and building text snippets for EntitySQL methods works well, C# scripting for LINQ not so well.

Automation that allowed sending generated C# scripts for LINQ (or other snippets) to LINQPad
and return of results such as collections, possibly through html piping would be wonderful!

Ross
0

#10 User is offline   mcintyre321 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 16-April 09

Posted 26 May 2009 - 08:40 AM

It would be really cool if .linq files were actually compiled exes which we could then call from the command line or reference in our .NET projects. The script content itself could be read from some metadata.
0

#11 User is offline   mcintyre321 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 16-April 09

Posted 10 July 2009 - 06:36 AM

Is there any news on this front?
0

#12 User is offline   JoeAlbahari 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 529
  • Joined: 15-February 08
  • Gender:Male
  • Location:Perth, Australia

Posted 15 July 2009 - 05:43 AM

Development on LINQPad has been quite slow lately - because I'm completing on C# 4.0 in a Nutshell. Most of the work on this will be finished soon - and they I'll start on the next LINQPad update. They'll almost certainly be something to support automation - whether it allows the compilation of standalone EXEs, I'm not sure though. I would have to see how easily I can remove the dependencies on LINQPad.

Cheers
Joe
0

#13 User is offline   AnunayKumar 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 14-January 10

Posted 14 January 2010 - 07:05 PM

I would like to call Dump() extension method from within Visual Studio. Is this possible? The output HTML could be written to Console, Output window or to the disk. It would be great if instead of HTML, the output of dump could be plain formatted text which is printed to the console or output window.
0

#14 User is offline   JoeAlbahari 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 529
  • Joined: 15-February 08
  • Gender:Male
  • Location:Perth, Australia

Posted 16 January 2010 - 07:11 PM

You can use LINQPad's XHTML Dump engine from within Visual Studio by adding a reference to LINQPad.exe and then doing this:

var writer = LINQPad.Util.CreateXhtmlWriter();

To call Dump(), simply call Write or WriteLine on the writer object.

When you want to view the output. call ToString() on the writer - if you write the output to a file, you can then view it in a web browser.

Cheers
Joe


0

#15 User is offline   AnunayKumar 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 14-January 10

Posted 21 January 2010 - 01:16 AM

Joe, thanks for adding this to the new Beta. I have written following extension method to simplify debugging in Visual Studio.
CODE
public static string Print<T>(this T o)
{
var writer = LINQPad.Util.CreateXhtmlWriter();
writer.Write(o);
return writer.ToString();
}
To view contents of any variable during debugging, I simply add myVariable.Print() to the watch window and use Visual Studio's built in HTML visualizer to see the formatted XHTML.

Thanks a ton
Anunay

This post has been edited by AnunayKumar: 21 January 2010 - 01:17 AM

0

#16 User is offline   JoeAlbahari 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 529
  • Joined: 15-February 08
  • Gender:Male
  • Location:Perth, Australia

Posted 24 January 2010 - 06:25 AM

Nice smile.gif

Joe
0

#17 User is offline   War Wizard 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 12-February 10

Posted 12 February 2010 - 09:49 AM

Any more updates?
0

#18 User is offline   JoeAlbahari 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 529
  • Joined: 15-February 08
  • Gender:Male
  • Location:Perth, Australia

Posted 13 February 2010 - 04:47 AM

regarding XHTML output or automation?
0

#19 User is offline   mattipton 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 07-March 10

Posted 07 March 2010 - 12:19 AM

My 2 cents worth- First, LinqPad is awesome. And yes, the automation would be absolutely without a doubt a killer feature. In my opinion, as far as the automation goes, I'm not sure that building into an exe is not a "must have"... but just having the ability to automate execution is the main thing... Like say having the ability to make a command line call to execute a given .linq script would be fine with me. You know, like say for me, I'm always wanting to batch stuff up but keep in separate .linq files for organization... so command line call would be perfect... anyway, there is my use case. Keep up the great work!

This post has been edited by mattipton: 07 March 2010 - 12:26 AM

0

#20 User is offline   Naveen S 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 27-January 10

Posted 23 March 2010 - 09:44 AM

QUOTE (JoeAlbahari @ Feb 13 2010, 04:47 AM) <{POST_SNAPBACK}>
regarding XHTML output or automation?


On Automation?
0

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users