How to use the LinqPad Utilities for Microsoft Dynamics
For the time being, feel free to examine the samples that come with the utility to see how to use it.
You can also type
This will display the following information within LinqPad itself.
LinqPad CRM Utilities
Before starting, make sure your LinqPad is working, and that you have previously been into the Extensions and ran them to create the appropriate LinqPad folders.
The first thing you will need to do is Install the sample files. From a LinqPad Query window, type DynamicsCrmOrgUk.Utility.InstallFiles(); and run it. If you have LinqPad installed, the process should be automatic, however, if you are running LinqPad in Portable Mode, then you may be prompted to specify certain folders.
Please be aware that this will replace your extensions file. If you wish to install the snippets and sample queries, then please type DynamicsCrmOrgUk.Utility.InstallFiles(false); to keep your existing extensions.
If you’re using a registered version of LinqPad, the easiest way to get started is to type Dynamics and press the TAB key. This should use the sample Snippet that contains a sample query and all references and Namespaces to use the library.
If you cannot use a Snippet, you can either open up your extension and run it (assuming you installed it) to begin setting up your CRM connections.
|Utility.About();||Displays information about the plugin.|
|Utility.Help();||Displays help information showing the commands you can use.|
|Utility.EditCRMConnections();||Displays a grid where you can add and edit CRM Connection Strings to be used to Connect to Microsoft Dynamics.|
|Utility.InstallFiles(bool installExtension = true);||Installs a snippet called Dynamics that is pre configured for use with the Utility, installs a “My Extensions” script (optional) that configures up Namespaces for your Queries, and installs some sample Queries to help get familiar with the Utility.|
|Utility.InputBox(string message);||Request a string input from the user and returns it.|
|Utility.GetFolder(string type);||Shows a Folder selector and returns the selected Path to the calling script.|
|Utility.OpenFile(string fileType,string fileDescription);||Shows a file selector and returns the chosen Filename to the script.|
|Utility.SaveFile(string fileType, string fileDescription);||Shows a file save selector and returns the chosen Filename to the script.|
|Crm.GetContext(string connection, string connectionString = “”);||Connects to the specified connection (and also using the optional connection string) and returns an OrganizationServiceContext object.|
|Crm.ResetConnection();||Resets any current connections.|
|Crm.GetService(string connection)||Connects to the specified connection and returns an IOrganizationService object.|
|Crm.GetRecordById(string logicalName, Guid id);||Returns an Entity Record of the type specified by the logicalName and with the Guid specified.|
|Crm.GetAttributeLabel(string logicalName, string attribute);||Returns the Attribute display label for the specified entity/attribute.|
|Crm.GetValueFromUnformattedAttribute(object attribute);||Returns the appropriate value for an Attribute based on its type.|
|Crm.GetRecordCount(string logicalName);||Returns the total number of records for the entity with the specified logical name.|
|Web.Get(string url);||Performs a GET against a web service specified by the URL and returns the data.|
|Web.Post(string url, string contentType, string data…);||Performs a POST to a web service url.|
|Test.Run(string Environment, bool DumpResults, string Name, params string args);||Runs a named script, using the specified named connection.|
|Test.RunTest(string Environment, bool DumpResults, params TestSteps args);||Runs a number of scripts sequentially, passing the result from one script into the next.|
|Test.RunTestAsync(string Environment, bool DumpResults, params TestSteps args);||Runs a number of scripts in parallel.|
|Test.Start();||Starts the timer.|
|Test.Pause();||Pauses the timer.|
|Test.Wait(int nSeconds);||Waits n number of seconds.|
|Test.Stop();||Stops the timer and outputs the elapsed time.|
|Test.Reset();||Resets the timer.|