I recently came across a program called LINQPad and decided to give it a try.

What is LINQPad

LINQPad is a software utility targeted at Microsoft .NET development. You can use the tool to write C# code without the need for an IDE (Visual Studio for example) and quickly prototype your code. On their website they state:

Put an end to those hundreds of Visual Studio Console projects cluttering your source folder and join the revolution of LINQPad scripters and incremental developers.

Sounds exactly like what I’m currently doing, creating a lot of Visual Studio Console projects for testing my CRM developments. Let’s evaluate if LINQPad could be of any personal benefit.

Getting started with LINQPad

You can download LINQPad 5 here. After installing LINQPad and running LINQPad for the first time, we get the following window:

First time launch of LINQPad

(Optional) Configure LINQPad to use a Proxy server

If your client/company uses a Proxy server, you should configure LINQPad to use this Proxy server. If not, just skip this part.

Edit the config file under  C:\Program Files (x86)\LINQPad5\LINQPad.exe.config. Add the following below the <configuration> tag (don’t forget to change the value of proxyaddress):

[code language=”xml”]
<defaultProxy enabled=”true” useDefaultCredentials=”true”>
<proxy proxyaddress=”***” autoDetect=”True” usesystemdefault=”True” />

Next, make a copy of the file ‘LINQPad.exe.config’ in  the same directory to ‘LINQPad.config’.

The reason we make a copy of the config file is because LINQPad uses LINQPad.exe.config for the GUI and ‘linqpad.config’ for your queries. We need our proxy settings in both cases.

Connecting LINQPad with CRM

There are two main ways to connect LINQPad with Dynamics CRM. We can either utilize the .NET CRM SDK libraries and write our own C# code for handling the connection etc or we can use a CRM LINQPad driver (developed by Kenichiro Nakamura) that handles all the connection stuff for us.

Using Microsoft Dynamics CRM LINQPad Driver

Install the Microsoft Dynamics CRM LINQPad Driver

Installing the Microsoft Dynamics CRM LINQPad Driver is pretty simple. In LINQPad, first click on ‘Add connection’ (1) followed by ‘View more drivers…’ (2). Finally choose the ‘Download & Enable Driver’ from Microsoft Dynamics CRM (3).

Steps to install the Microsoft Dynamics CRM LINQPad Driver

FYI, the source code of the Dynamics LINQPad driver can be found on GitHub.

(Optional) Add LINQPad to ADFS for IFD

For IFD environment, you have to register the application before using the driver. If this is not the case, you can skip this part.

  1. Login to AD FS server
  2. Open PowerShell as admin
  3. Run (after you changed Guid):
    Add-AdfsClient -ClientId D3B990FE-FA45-4902-A151-60D5466ABC97 -Name “CRM For Linqpad” -RedirectUri http://localhost/linqpad
  4. Make note of the Guid and the RedirectUri

Connect LINQPad to your CRM instance

Click ‘Add connection’ and choose the Dynamics CRM Web API Linq Pad driver, click Next and login to your CRM instance.


Uncheck ‘Register to Azure AD automatically…’ if you have an IFD environment. Fill in the ClientId and RedirectUri you previously configured. Otherwise just leave the checkbox checked.

Connecting to CRM with IFD authentication

When you are successfully connected and the data content is downloaded, you should be able to browse through the schema of the organization.

CRM schema

Execute a LINQ Query

Start by creating new query window (CTRL + N), select Language to C# Expression and set the Connection to the connection you previously created.


For example: to retrieve all contacts, use the following LINQ query and press F5 to execute:

[code language=”csharp”]
from c in contacts
select new
contact_firstname = c.firstname,
contact_name = c.lastname

The results will be shown under the Results-tab. Below the SQL-tab you can find the WebApi equivalent of our query, for our example this would be: https://***//api/data/v8.1.0.359/contacts?$select=firstname,lastname

Keep in mind that not all conditions that can be expressed in LINQ are supported, it’s limitations can be found on msdn, here.

Next to using the Dynamics CRM LINQPad Driver, we can also utilize .NET libraries and write our own C# code to be executed.

Using .NET SDK libraries

Referencing custom assemblies in LINQPad is pretty simple. In your query window, just press F4 to open the query properties window. In the Additional References tab you can Add/Browse for custom assemblies. Add your required CRM SDK & .NET assemblies, you can always add more later by pressing F4 again.

Adding additional references to a LINQPad query

Next, you can write your C#code as you would using a console app in Visual Studio. Make sure you change the ‘Language’ to ‘C# Program’.

For example a WhoAmIRequest returning the orgId:


LINQPad uses the Dump() method to print the result on the screen.

I can imagine it would be very useful to have some saved LINQPad queries in your personal toolbox. For example to execute a custom action, to retrieving specific records,…

Good luck!

Leave a Reply