Home

How to use load directive in query that's called by Util.Run

Hey, I couldn't find a thread about these two features in tandem.

I have a number of queries (all in the same directory) that I want to add to version control, and be able to run them from anywhere on users' computers.

Util.linq -> doesn't reference any other queries, but has methods I want accessible
QueryA.linq -> needs to #load code from Util.linq
QueryB.linq -> needs to #load code from Util.linq
Runner.linq -> calls both QueryA and QueryB using Util.Run()

I've tried various combinations of using .\ in the load directive, and adding/removing Directory.SetCurrentDirectory() as suggested here. Either it can't find the path to the Util.Run(QueryA / B) (if I use relative path and don't set CurrentDirectory) or can't compile, because it doesn't recognize the code from Util.linq (when I SetCurrentDirectory). I also need to be able to run Query A and B on its own (which does work properly with #load ".\Util.linq")

It works for me fine if I have everything in a folder within "LinqPad Queries" and I reference it using Util.Run("folderName\\QueryA.linq"). But I need for the whole folder to be portable.

Thanks,
-Michael

Comments

  • There's no good reason for Util.Run to apply different logic to #load for relative file resolution (with the exception that Util.Run should also allow paths relative to Environment.CurrentDirectory). I'll fix this in the next beta.

Sign In or Register to comment.