Thursday, August 18, 2011

A better way to learn LINQ-to-CRM





In Microsoft Dynamics CRM 4.0, we introduced LINQ for our developers through the Advanced Developer Extensions for Microsoft Dynamics CRM 4.0 toolkit. We have further improved this support in Dynamics CRM 2011 by including LINQ as a first class data query mechanism. A better alternative to QueryExpression, LINQ provides a simple, intuitive and unified approach for data retrieval across different data sources.

Those of you who already use LINQ in some other .NET projects are possibly familiar with a great tool that makes LINQ developers’ life easier – LINQPad (www.linqpad.net). LINQPad is similar to SQL Management Studio – it lets you connect to various data sources (for which LINQ providers exist), examine their structure (just like you do with tables and columns in SQL Management Studio), and, finally, write and execute LINQ queries on a fly. LINQPad is a terrific tool to experiment with LINQ. It eliminates a need to create a separate sample C# project to test your queries.

I have written a new tool “LINQPad Plugin for Microsoft Dynamics CRM 2011” to help CRM developers learn and test LINQ queries against any CRM 2011 deployment. The project is available for download from its MSDN Code Gallery page - http://code.msdn.microsoft.com/crmlinqpad

The application is fairly easy to use. You create a connection to a CRM organization by entering organization URL and credentials, and then the plugin retrieves information about the organization’s entities. A tree-like structure of entity sets and entity attributes will be displayed on the left panel of the application. Once that is done, you can write and execute LINQ statements from the main application window. The results of the execution will be shown in a table on the bottom panel.


Features
1) Support of all Microsoft Dynamics CRM 2011 deployment types: Online, OnPremise and SPLA
2) Entity schema browsing – navigating through entity sets, entity attributes and relationships
3) Writing and executing LINQ queries against entity sets
4) Examining QueryExpression used for actual data retrieval

Installation instructions
1) Make sure you have .NET Framework 4.0 and Windows Identity Foundation installed
2) Download and install LINQPad for .NET Framework 4.0 from http://www.linqpad.net
3) Download CrmLINQPadPlugin.lpx from http://archive.msdn.microsoft.com/crmlinqpad/Release/ProjectReleases.aspx?ReleaseId=5329
4) Run LINQPad and register the plugin – go to "Add Connection\View More Drivers\Browse" and select CrmLINQPadPlugin.lpx
5) To create a CRM connection, click "Add Connection" and select "MS CRM 2011" in "Use a typed data context from your own assembly" section



The plugin supports all CRM deployment types – Online, OnPremise and SPLA.
More instructions on how to download and configure LINQPad and the plugin can be found in the Home section of the plugin’s MSDN Code Gallery page.


No comments:

Post a Comment