LINQ to Sharepoint (SPLINQ)

SPLINQS’s advantage over CAML:

* CAML is hard to use because it is XML based.
* CAML offers no compile time validation.
* If CAML syntax is wrong, you won’t get error message at runtime.

To use SPLINQ, we need to know where to find the list data – using REST service/ASP.NET Data service, which is :

In order to use the objects returned by the listdata.svc service we need to generate the entity classes for the list objects returned by the service and add those entity classes to the application that is supposed to work with the list data. There are two ways to do that.

(1) The first way is to use SPMetal.exe

SPMetal.exe is here:
%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\BIN

(2) Add Service Reference in VS 2010.

Exercise – Create a Console App that uses SPLINQ

Create a new project, Windows Console App. Add Service reference to:

Add a reference to Microsoft.Sharepoint.Linq.dll:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI

Next, add these two using:

using System.Net;
using Microsoft.Sharepoint.Linq;

[The address in the Uri(…..) is the same as the ASP.NET Data Service URL]

Add item —

Retrieving and displaying all items in a list —-

Update an item —

Delete an item —


CRUD (Creat/Read/Update/Delete)

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: