Why use LINQ instead of CAML
- Compile-time type checking
- You don’t have to know CAML which is not as well documented.
- If you know LINQ to ??? you already have a good feel for the syntax.
From what I can tell (I found conflicting information on this and I could not get it to work) you can’t use spmetal (which is required for LINQ to SharePoint) on SharePoint Online. However, if you are using SharePoint 2010 (on premise) it does generate ok, so I expect the LINQ to SharePoint would work as expected.
Learn more about LINQ to SharePoint
- Introducing Linq to SharePoint Video – Good place to start.
- LINQ Syntax Video – Learn the basics of the syntax for general LINQ (if you don’t know it already)
- Accessing SharePoint Data using LINQ to SharePoint
- Create Entity Classes using SPMetal
- Add reference to Microsoft.SharePoint.Linq.dll to your project
- Create DataContext
- Write Queries