Friday, 4 June 2010

Linq to SharePoint overview

Problem: Access data in SharePoint Lists.
1.> LINQ for SharePoint is a data access mechanism that allows developers to create SQL like syntax against a data sources. Linq improve performance by allowing the back end data source to be queried using CAML to solve the query. SharePoint 2010 fully supports LINQ for lists so that developers can query SharePoint easily and quickly.
2.> LINQ for SharePoint is also know as SPMetal.
3.> The SPMetal utility generates C# or code to allow you access to existing SharePoint lists.
4.> You can automate you VS environment using the prebuild cmd prompt to regenerate your Linq data access class for builds.
Steps to work with Linq for SharePoint:
1.> Using the stsadm cmd, create the API to your existing SharePoint App

2.> Import the created Data.cs file into the Visual Studio solution. Fix the namespaces on the file.
3.> Begin Using LINQ to SharePoint.
DataDataContext dc = new DataDataContext(http://intra);
// TODO! - retrieve from the web.config
EntityList Assets;
Assets = dc.GetList("My Assets");
var assetQuery = from asset in Assets
where asset.Id == Assetid
select new{

// Bind to a Grid view

More Info:
Getting started with LINQ for SharePoint 2010
Channel 9


Post a Comment