Home
Options

Get Currently Running Query

I've recently been tossing around ideas for extensions, specifically for new output windows. One thing I'd like to do is present some additional information on the currently running query (for example, the way that the IL output window shows the decompilation of the current query). I've figured out how to add output windows, how to manipulate them after the query has finished, and how to create extension libraries. Unfortunately, I can't for the life of me figure out how to get information (especially the text) of the currently running query.

Is this possible? I've looked in the Util class and searched through decompiler sources, but I can't find a public entry point for this. I've also found the new .Compile() API, but that seems relevant to other queries, not the current one.

Thanks for any guidance you can provide!

Comments

  • Options
    edited March 2015
    An automation interface has been on the wishlist for a while, but has been pushed back by other new features. The plan is for it to be built around LINQPad.ObjectModel.Query, so there would be a Util.CurrentQuery property which would return a Query object with properties to manipulate it.

    Right now, though, there's no way to get a the query other than Util.GetCurrentQueryPath, and this returns null if the query hasn't been saved, or a stale reference if modified.

    The best you've got right now is Assembly.GetExecutingAssembly(). This will give you the IL, but not the source.

    Edit: I've just uploaded a beta with a Util.CurrentQuery. It's incomplete in that you can't get at all the query properties, but you can see the query text, and there's a GetRawHeader() method which gives you everything else in an XML form.
  • Options
    That's perfect, thanks!
Sign In or Register to comment.