LINQ to SharePoint 2010

The LINQ to SharePoint Provider is defined in the Microsoft.SharePoint.Linq namespace. It translates LINQ queries into Collaborative Application Markup Language (CAML) queries. It is no longer necessary for developers to know how to write CAML queries. LINQ queries can be used in server code. To query from a client application, use SharePoint’s support for ADO.NET Data Services.

The gateway class for the LINQ to SharePoint provider is Microsoft.SharePoint.Linq.DataContext which represents the data of a SharePoint Foundation Web site.

It is parallel in use and function to the System.Data.Linq.DataContext class in the LINQ to SQL provider. Just as the latter class has a GetTable method that returns a Table(Of TEntity) object that implements System.Linq.IQueryable(Of T), the Microsoft.SharePoint.Linq.DataContext class has a GetList(Of T) method that returns an EntityList(Of TEntity) class that implements System.Linq.IQueryable(Of T). It is objects of type EntityList(Of TEntity) that are queried.

The following is an example of the use of LINQ to query SharePoint Foundation.

Copyright © All Rights Reserved - C# Learners