NY.Dataverse.LINQPadDriver
1.7.5
dotnet add package NY.Dataverse.LINQPadDriver --version 1.7.5
NuGet\Install-Package NY.Dataverse.LINQPadDriver -Version 1.7.5
<PackageReference Include="NY.Dataverse.LINQPadDriver" Version="1.7.5" />
paket add NY.Dataverse.LINQPadDriver --version 1.7.5
#r "nuget: NY.Dataverse.LINQPadDriver, 1.7.5"
// Install NY.Dataverse.LINQPadDriver as a Cake Addin #addin nuget:?package=NY.Dataverse.LINQPadDriver&version=1.7.5 // Install NY.Dataverse.LINQPadDriver as a Cake Tool #tool nuget:?package=NY.Dataverse.LINQPadDriver&version=1.7.5
Dataverse Driver for LINQPad 6
The original LINQPad Driver for Dynamics CRM (as Dataverse was known back then) was written by Kenichiro Nakamura. It used the SOAP endpoint along with CrmSvcUtil to generate the early bound classes needed to show the entities in LINQPad. It was a static driver, meaning that you had to regenerate the context if you had new metadata e.g. new fields, entities etc.
This new driver is a dynamic driver that uses Microsoft.PowerPlatform.Dataverse.Client assemblies which targets .NET 5. The Tables (Entities) and associated metadata are regenerated everytime LINQPad is opened, so that you don't need to worry about keeping Dataverse Metadata and LINQPad context in sync.
Installing
You can install the driver from LINQPad from nuget. Click on View more drivers, and then choose "Show all drivers". Search for Dataverse and you should be able to see the driver and install it.
<img src="images/newconnection.png" alt="View more drivers" />
<img src="images/install.png" alt="Install" />
Connecting to your Dataverse Environment
Microsoft.PowerPlatform.Dataverse.Client supports four kinds of authentication:
- Application Id/Secret
- Application Id/Certificate Thumbprint
- OAuth
- Azure
After installing the driver from nuget, you can start using this driver by clicking Add Connection link on LINQPad. You will be presented with the dialog below.
<img src="images/connection%20details.png" alt="Connection Details" />
The easiest way to connect is to use the credentials you already have in Azure CLI. You can get the currently signed on user in Az CLI using the command below.
az ad signed-in-user show --query "{login: userPrincipalName, name: displayName}" --output table
This should display something like below.
<img src="images/Az%20CLI.png" alt="Connection Details" />
If you choose Azure connection method, you only need to enter the environment URL e.g. https://env.crm.dynamics.com. If you choose any other connection method, you have to enter the appropriate details i.e. AppId/Secret, Certification Thumbprint etc.
Running LINQ Query
After entering the required details on the connection dialog, the context would be generated and you should see all the tables on the left hand side.
<img src="images/entities.png" alt="Tables" />
You can either write a new LINQ query on the query window, or right click on the table name, to see some quick suggestions.
<img src="images/queryoptions.png" alt="Query Options" />
LINQPad has a whole bunch of samples on how to craft your LINQ queries, in case you don't know how to query in LINQ and want to learn the syntax. LINQ is very similar to SQL in syntax, but more powerful than SQL.
<img src="images/samples.png" alt="Samples" />
I have also given five samples that illustrate the power of LINQPad and how you can use the driver to query Dataverse.
<img src="images/dataverse%20samples.png" alt="Dataverse Sample" />
I highly recommend that you purchase LINQPad Premium, as you get both Intellisense and Debugging capability. It is great for quick PoCs and experimentation. I currently get a free Premium licence as a Microsoft MVP, but I had paid for Premium licence even before I became a Microsoft MVP.
Calling Dataverse API
You can use DataverseClient property to access the ServiceClient object. Once you have access to this object you can then basically do any operations that are supported by the client.
<img src="images/dataverseclient.png" alt="Dataverse Client" />
Getting FetchXML/WebAPI URL from LINQ
If you click on the SQL tab, you can see both WebAPI URL and FetchXML that correspond to the LINQ query that you ran.
<img src="images/linq%20to%20fetch.png" alt="LINQ to FetchXML" />
Thank You
- Mark Carrington for FetchXML to WebAPI URL conversion logic
- Kenichiro Nakamura for writing the original CRM driver for LINQPad 4.
- Gayan Perara for CRM Code Generator, which was the first one to use T4 templates for generating early bound classes
- Joe Albahari for creating LINQPad and providing Microsoft MVPs with Premium licence
- People who helped me with testing - Tae Rim Han
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
-
net6.0-windows7.0
- Azure.Identity (>= 1.10.4)
- LINQPad.Reference (>= 1.3.0)
- Microsoft.PowerPlatform.Dataverse.Client (>= 1.1.16)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Update Azure Identity (1.10.4) and Dataverse Client (1.3.0) packages