This post explains how to use LINQPad to test and debug LINQ statements with Sitecore 7.
If you use LINQ, you are probably already aware of LINQPad. It is a helpful tool quickly writing and testing LINQ statements. It's especially helpful if you're learning LINQ, or if it's something you don't use too often and need a refresher.
Sitecore 7 includes the LINQScratchPad, which is a great tool in its own right. But LINQPad gives you auto-complete (in the $40 pro version) and debugging, so it has some advantages.
There are different ways you can get the Sitecore 7 search provider to work in LINQPad. This post describes how I configured my system.
Your config file should look something like the following (almost every setting has been removed for simplicity):
var index = ContentSearchManager.GetIndex(
(var context = index.CreateSearchContext())
.Where(item => item.Name ==
.Where(item => item.DatabaseName ==
.Where(item => item.Language ==
When you execute your query, you may get one or more of the following exceptions. These exceptions indicate the LINQPad.config file is not correct.
Whenever you change LINQPad.config, you must restart LINQPad in order for the changes to take effect.
This post depends on tips from the following blogs:
Any thoughts on how to get LinqPad to work when using Solr for search?
Hey Adam, Took a stab at getting this working with a Solr implementation. Got things working using these steps: www.paragon-inc.com/.../using-linqpad-with-sitecore-7-and-solr
I tried to use the LINQPAD and configured all the setting as mentioned but I am getting the following error after running the code in result section. Could not read Sitecore configuration. Message Could not read Sitecore configuration. Data (0 items) InnerException null StackTrace at Sitecore.Configuration.Factory.GetConfiguration() at Sitecore.Configuration.Factory.GetConfigNode(String xpath, Boolean assert) at Sitecore.Configuration.Factory.CreateObject(String configPath, String parameters, Boolean assert) at Sitecore.Configuration.Factory.CreateObject(String configPath, Boolean assert) at Sitecore.ContentSearch.ContentSearchManager.get_SearchConfiguration() at Sitecore.ContentSearch.ContentSearchManager.GetIndex(String name) Source Sitecore.Kernel HResult -2146233079
My config doesn't contain ApplyOutboundIndexFilter processor but i got 'The Role Manager feature has not been enabled' error message, any idea how to avoid this error?
Hi Andras, I would double-check your config file. The only time I've seen that error message is when that processor is included in the pipeline. Another option is to use the LINQPad driver for Sitecore that I wrote about: www.sitecore.net/.../LINQPad-Driver-for-Sitecore.aspx
hi I am getting error The type initializer for 'Sitecore.Diagnostics.LoggerFactory' threw an exception. Message Object reference not set to an instance of an object. StackTrace at Sitecore.Diagnostics.Log.Error(String message, Exception exception, Type ownerType) at Sitecore.Diagnostics.Log.Error(String message, Type ownerType) at Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) at Sitecore.Configuration.Factory.LoadAutoIncludeFiles(XmlNode element) at Sitecore.Configuration.Factory.GetConfiguration() at Sitecore.Diagnostics.LoggerFactory..cctor()