Install Instructions

To Install the plugin, simply download it from here.

 

Make sure your LinqPad (version 4 or 5) is set up correctly and you can use it.

Double click My Extensions in the bottom left pane to bring up the core extensions module.  Hit the Green triangle (the run button) to ensure the extensions compiles, and creates the appropriate folder structure.

Next, you need to find out where your Plugin Directory is (most commonly in your My Documents folder).  To do this, click the Edit menu, select Preferences, and look in the Folders tab to see where your Plugins and Extensions folder is.

Close down LinqPad.

Next, copy the DynamicsCrmOrgUk.dll assembly from the Zip file to the Plugins folder.

Relaunch LinqPad.

In the empty Query window that appears when you run LinqPad, type the following :


DynamicsCrmOrgUk.Utility.About();

Make sure the Language is set to C# Statement(s) and run it.

This should output information about the assembly and verify that you have it installed correctly.

Next, you will want to install all of the sample files, the My Extensions file, and the Snippet (if you have a registered version of LinqPad).

In the Query window, type


DynamicsCrmOrgUk.Utility.InstallFiles();

Note, if you have used LinqPad before, and you already have a customised “My Extensions” file, then you want to do InstallFiles(false) to prevent your file from being overwritten.

Depending on how your LinqPad is set up, and which version you are using, you may get several prompts to specify where your folders are.  Simply use the file selector to point to your LinqPad folders.

If it was successful, you should be able to close LinqPad, and restart it.

To check if it installed correctly, double-click the “My Extensions” in the bottom left window.  If everything goes according to plan, you will be prompted to download some NuGet packages.

This should then show you the My Extensions query that is provided with the Utility library.  Note that after the My Extensions has been installed, you should be able to refer to the library without the DynamicsCrmOrgUk namespace.


void Main()
{
Utility.About();
//Utility.Help();
Utility.EditCRMConnections();

}

If you run it, it should then provide you with the CRM Connections screen.

This Connections screen is used to set up your CRM Connection strings.  For example,

TEST

Url=https://sometest.crm4.dynamics.com; Username=james.hall@sometest.com; Password=p@ssword1;authtype=Office365

Always remember to click the Save button when your done.  The connections are saved in a file called connections.xml and is stored in your Query folder.

You will also have access to a number of samples which show some of the features of the utility library.

These samples should be ready to run.  If you do run a sample, one of the first things that will happen is it will prompt you for which connection to use as defined in the Edit Connections screen.

If you have a registered version of LinqPad, there will also be a Snippet available for you to use which will convert a blank query in a ready to go CRM script with all required namespaces and references.

Simply type Dynamics and press the TAB key to insert the Snippet.


//Sample Snippet to show how to query CRM

void Main(string[] args)
{
// Instantaites a QueryConext utility object.
QueryContext query = new QueryContext(args);

// Defines the name of each parameter if required for user input.
query.DefineParameterLabels("Domain Username","Some other parameter");

// When using query.Context, query.Service or query.Parameters[1-5], the user will be prompted for the connection to use,
// or the parameter value if they were not passed in to the script.
Entity user = (from u in query.Context.CreateQuery("systemuser")
where (string)u["domainname"] == (string)query.Parameters[0]
select u).FirstOrDefault();

// DumpEntity is a special version of LinqPad's Dump command which only outputs attributes and formatted values from an Entity.
user.DumpEntity();

}

After inserting the snippet, make sure the query language is set to C# Program.

How to use the LinqPad Utilities for Microsoft Dynamics