Thursday 10 March 2011

LinqPad on SharePoint data

Linq to SharePoint is great! The SPMetal.exe is really easy to use (see here how to use it).
But I was struggling a bit to get the right Linq queries. So I thought, well let's use LinqPad. I ran into the following error message:
PropertyOrFieldNotInitializedException: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
I searched for a solution, but I didn't find one. Today I figured out how to use LinqPad to query on SharePoint data, without facing these security-IIS-related issues.
On CodePlex you can find the LinqPad Data Context Driver for SharePoint created by a guy named 'theiwaz'. Creating a new connection in LinqPad, using this driver did the trick. Read the documentation how to install and setup the configuration (very easy!).

In my situation, I ran into a small problem. The documentation shows a screenshot with a sample code, using "C# Expression" a the language.
When I tried that, it failed. I got the following message:
String was not recognized as a valid Boolean
 Changing the language to "C# Statement(s)" did the trick for me. I only need to rewrite the code a little bit. But that's actually a great advantage, because it now looks like the code as I will use inside my VS2010 project.
var q = from prod in Products
    where prod.Customer.Title == "DNM"
    select  prod.Title;



Anonymous said...

Hey Robje,

I just want to announce that there is a new release of this driver which allows "on the fly" generation of the SharePoint entities to be used with LinqPad.


Rob said...

Hey theiwaz,

Thanks for this update reminder! I will have a look soon.

klaus said...

I recently used Fast passport services for a last-minute work assignment abroad, and I couldn't be happier with the experience. The regular passport application process can be quite time-consuming, with wait times extending for weeks or even months. However, with a fast passport service, I had my passport ready within a few weeks. The convenience and efficiency were incredible. Plus, the customer support I received was top-notch; they guided me through the entire process and ensured I had all the necessary documents. For work or personal reasons, fast passport services are a fantastic option for anyone needing a passport in a hurry.