LINQPad automatically makes available any snippets which are configured in Visual Studio. For example, if you type ‘cw’ (for Console.Writeline), LINQPad will inform you that it is aware of the snippet and prompt you to press Tab to insert the snippet at the cursor.
It is also possible to create your own snippets in LINQPad, giving you quick access to blocks of code which you need regular access to.
For example, take a look at the script below. This is the bare minimum which you might need to connect to CRM from LINQPad without using the CRM Driver for LINQPad, as described in this post.
Turning the ‘ConnectToCrm’ method into a snippet for reuse in other scripts could not be easier. Select the code that you want to turn into a snippet (in this case the ‘ConnectToCrm’ method).
Press ‘F4’ to access the Query Properties and then press ‘Save as snippet…’. The Create Snippet dialogue box appears:
Make sure that you tick the ‘Code’ tickbox. Click Next and save the snippet in the suggested location with a sensible name (such as ‘ConnectToCRM’).
LINQPad will confirm that your snippet has been saved.
In a new c# program script, your snippet will be available to use:
Press tab to insert the snippet and F5 to run the script:
Your script should automatically contain the right references and run without any problems.
Leave a Reply.
Some stuff about me!