Define query templates
I'd like to see a feature which allows users to create a 'query template' which can be used as a starting point for any new query .
A query template would have preset properties, references/usings, database connections, code, etc. and users can create as many templates as they like.
This is not much unlike using a saved query, but the difference is that users are not be making changes to the original when they create a new query from a template.
John Organiser commented
I like the idea of Template, it is useful in many ways to get boiler plate code, instead of over polluting My Extensions. Also like the idea to have templates listed in the Language drop down or similar, plus allow to save context in the template, which of course can be changed.
I would like to distinguish query templates by prepending an underscore to the filename. Then double clicking the file would force it to open as a template.
David Mårtensson commented
Using a solution where you can select context like you select connection you could very easily test the same code against different releases of the includes, like development and release to see if the results are the same.
And for me, We have 4 major products I work with and some classes and extension methods that exists in more than one of them so including all assemblies does not work, I get error that the same signature is declared multiple times.
And we also use development, test and release for each project resulting in a total of 12 different possible contexts to run in.
Using a selectable context would make it so much more convenient :D
Saved queries is an option but I have tried it and I just fail to "save as" overwriting the template :/
Daniel Rubin commented
You can almost accomplish this with snippets, if you have auto-complete (I don't know if you can use snippets without it). You can use them to import a set of references and using statements into the current query, but I don't know if it does database connections and it doesn't do code.
David Mårtensson commented
I was just about to suggest something like this but more like a Context that I could choose for a query.
By selecting a context I get all the above but with contexts I could also switch context.
Like testing the same query towards different builds of the same product.
In my case I have methods that are named the same in two different projects and if I include both they become ambiguous.
But since changing references and namespaces is cumbersome I have all included and remove the unnecessary once, but this also is a bit irritating to have to do.
Please implement something like this :D
Excellent idea. I regularly use LINQPad with my own assemblies so that I can use data access methods defined in them - transactional specification-based querying, for example - and this often requires a few lines of setup which become quite tedious to type in every new query.
John Morrison commented
Would love this - esp if you could choose them as a 'Language' option... for example, a lot of my play code uses automapper and I've some template code which isolates this. I would like the default query for Language: C# program to use this template query.
Dave Shaw commented
I currently save queries and Mark them as "Templates" and at the top of the Query put "\\Clone Me". I then open them and "Clone" the Query before I do any work.
Renato Golia commented
I'd really like to see this implemented :)