Hey guys,
this is the second part for Linq To SharePoint, if you have missed the introduction please click here
Getting Started:
- Open Visual Studio 2010
- Create a new SharePoint Project e.g. EventReceiver
- Import your existing Entity Class which has been generated before (Add->Existing Item -> SampleEntities.cs)
- Add Microsoft.SharePoint.Linq reference to the project (Reference -> Add -> .Net Component -> Microsoft.SharePoint.Linq)
Now your project should look like the following structure:

Coding:
before you can use Linq functionalities you need to add the following using statements within your eventReceiver class:

Now we can instantiate an object with the generated EntityClass and fetch some data in depending on the where clause.
In this sample I only want to receive the item which has been added and had the Source equal to "Test".

The most cool new thing is intellisense, which you'll never find using CAML Query. Have a look at this:

You can use Linq To SharePoint to fetch, add, update or delete data here are some samples for this:
Update Sample:

Delete Sample:

Add Sample:

Happy Coding :)
cheers
Posted
Dec 27 2011, 03:24 PM
by
Nadine Storandt