Search This Blog

Wednesday, September 19, 2012

Using LINQPad for SharePoint Development

Well may be you are already familiar and using this but if not - please continue reading.
While Visual Studio 2010 /2012 are great editors for SharePoint Development, there is another tool which we can use for quick function writing and testing. It's called LINQPad

http://www.linqpad.net/

It's a small footprint application with no installation components - just one self contained exe.
I have used this for testing functions and then copy over to large SharePoint projects so that building and testing the function is easier than testing the same function in a large application.
Though there is free version also but in my opinion that is useless i.e. without intellisense it will make it difficult to program. The Pro version is only around $35 - ask your boss and he will not have any issues with that. That same copy of license can be installed on multiple machines which you own and use - that is another plus.


How to setup for SharePoint development:

After downloading the application, run the .exe.
The .exe does not run if it is renamed, so need to be LINQPad.exe only. There are multiple versions however the one which works with SP 2010 is .Net 3.5 version. The X86 and X64 versions do not work with SP 2010.

How to setup for SharePoint development:
After editor shows up, press F4.


Add the references from ISAPI folder. By the way all the references are not required and the bare minimum is Microsoft.SharePoint.dll . Click on set as default for new queries so that these are set for all code files we create henceforth.

Next click on the additional namespce imports tab and

and type in Microsoft.SharePoint.
Click ok.

From editot window - select C# program as shown below (we can use other options also) however this way we can write multiple functions in the same file and then call those from Main( )


The editor is ready to use now.

Overall Pros:
a) Lightweight
b) Low cost
c) Fast editor and with syntax highlighting and intellisense

Cons:
a) No step by step debugging (use .dump( ) function to write the values to output.
b) While testing with a SPWeb and using GetTemplates it cached the list of templates and that was a issue since after creating new Site Templates, the code did not show those. Closing the editor and re-opening fixed the issue.

Well we can not compare it with all the things VS.Net offers but for the given cost - it offers a lot.

Also this would not work with SP 2013 because it is built for .Net 3.5 SP1.
So far have used VS.Net 2012 with SP 2013 but not LINQPad .Net 4.0 and that may work with SP 2013.
If you try that please write back...


That's it and until next time...

-- Mohan

Disclaimer: Am not associated in anyway with LINQPad. The above is only based on personal experience on using this tool.


1 comment:

Henrik said...

Thank you very much for taking time to write this post.