Sitecore LinqScratchPad Extender

The LinqScratchPad allows a user to execute code snippets. As describe on the Sitecore Blog:

LinqScratchPad will allow you to run LINQ queries against your indexes all within the browser! Not only this but you can play around with different POCO’s, settings and also test the performance of your queries.

When executing the code, the result will be returned in a tabular form as shown below:

linqResult

However, there is currently a limitation with the LinqScratchPad. The user cannot execute code that is being referenced from the user’s own assembly. In this post, I will explain the module that I have developed so that it takes into consideration the user’s assembly.

The module name is called LinqScratchPadExtender since I am extending the module to a higher level. Currently, the LinqScratchPad allows only the following assemblies:

Sitecore Assemblies

  1. Sitecore.Kernel.dll.
  2. Sitecore.Buckets.dll.
  3. Sitecore.ContentSearch.dll.
  4. Sitecore.ContentSearch.Linq.dll.

System Assemblies

  1. System.dll.
  2. mscorlib.dll.
  3. System.Core.dll.

However, by extending the LinqScratchPad, the module will allow for using your own assemblies. Below is the screenshot of the new UI:

newLinqPag.PNG

In each textbox you can input the different assembly name. Moreover, compare to the current LinqScratchPad, you no more have to stick to the defined Namespace and Method name. You can use your own Method and Namespace.

Parameters are also available. Suppose you have a method that takes 2 parameters, you can easily now input its value in the Parameter Values textbox.

This extension of the LinqScratchPad will help if you have a Custom Property class that returns values from the Index.

To access the module, enter the path as follows:

[domain]/sitecore/admin/linqscratchpadextender.aspx

The module code is available on my GitHub Repository and is currently under reviewing mode on the Sitecore MarketPlace

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s