8/22/2007
LINQ to SharePoint - Part I
What is LINQ to SharePoint?
The LINQ to SharePoint project provides a custom LINQ query provider that allows you to query SharePoint lists using familiar LINQ syntax. LINQ stands for Language Integrated Query and is one of the core features of Microsoft's .NET Framework 3.5 release. This project falls under Ms-LCL License.
To find the latest news, check the web site at http://www.codeplex.com/LINQtoSharePoint.
There is also a LINQ to SharePoint blog which can be found at http://blogs.bartdesmet.net/linqtosharepoint.
The project features:
- Custom query provider that translates LINQ queries to CAML, the Collaborative Application Markup Language used by SharePoint for querying.
- Support for LINQ in C# 3.0 and Visual Basic 9.0.
- Entity creation tool SpMetal to export SharePoint list definitions to entity classes used for querying.
- Visual Studio 2008 integration for entity creation (a.k.a. SPML).
- Can connect to a SharePoint site either using the SharePoint object model or via the SharePoint web services.
- Planned support for updating through entity types.
Development is done by Bart De Smet. He is Microsoft MVP for Visual C# and specializes in various Microsoft-related technologies, covering .NET Framework development, CLR, C#, SQL Server and Windows Server System. Since the year 2000, Bart evangelizes Microsoft technologies and delivers presentations on several technology events. Beside his evangelism efforts, he's busy maintaining his blog, writing articles for the local MSDN website in Belgium and doing consultancy for various development projects, spending long and lonely nights with his computer. In 2005, Bart graduated as a Master Informatics from the university of Ghent, Belgium with a summa cum laude degree. Two years later he got a Master of Computer Science (Software Engineering) degree from the same university.
Blog: http://blogs.bartdesmet.net/bart
Where to get LINQ to SharePoint?
LINQ to SharePoint is available in several forms. Next to a regular installer (MSI-package) the project’s source code is also available for download. The reason for making the code available is to help others in implementing custom LINQ query providers. In order to use LINQ to SharePoint, one needs the .NET Framework 3.5. If you want to profit from the Visual Studio 2008 integration, you should have Visual Studio 2008 Professional or higher. (see http://go.microsoft.com/?linkid=7175502 to download Visual Studio 2008 Beta 2)
The installer and source for the latest release can both be found in the “Releases”-tab on http://www.codeplex.com/LINQtoSharePoint . The latest sources can be found via the “Source Code”-tab on the same web site.
If you’ve downloaded the source code, you will need the Visual Studio 2008 SDK in order to build the Visual Studio 2008 integration components. The SDK can be found here (http://www.microsoft.com/downloads/details.aspx?FamilyID=D9000E2C-BD3F-4717-A181-723960814E16&displaylang=en). If the SDK is not installed, you will get the following error:
To install the LINQ to SharePoint libraries, run the installer and this will automatically install the libraries and configure Visual Studio 2008. To use the library you can simply add a new LINQ to SharePoint file. You can do this by right-clicking the project, Add, New Item, selecting the LINQ to SharePoint file and clicking Add.
This will automatically add a reference to the library to your project.
If you want to manually add this reference, follow these steps::
1. Add the reference to the library by clicking the “Add Reference” item on the properties menu of your project (right-click on the project node in Solution Explorer and choose Add Reference…)
2. In the .NET-tab of the Add Reference dialog, select the LINQ to SharePoint runtime library (BdsSoft.SharePoint.Linq) and click OK.
3. In Solution Explorer, the library has been added to the references:
In your project’s source code, add a using-statement:
using BdsSoft.SharePoint.Linq;
Now the library is ready to be used.
Next week, there will be a post explaining SPMetal and some basic LINQ to SharePoint code samples to get you started.