- LINQ to sql class
Step 1: launch VStudio 2010 to create an empty SharePoint Project:
Step 2: add a new item and choose LINQ to SQL Classes. Name it AWEmployee.dbml
Step 3: launch Server Explorer to drag Employee tables into design surface. In AWEmpolyee.designer.cs, you will find a class named as AWEmployeeDataContext.
- LINQ to SharePoint
Step 1 use SPMetal utility to generate a datacontext or entity class, for eaxmple: SPMETAL /web:http://sp2010/ /namespace:sp2010 /code: EntityClasses.cs
Step 2: the resulting source file defines a datacontext class which in turn defines an inner class for each individual SharePoint list (update 04/19/2010: or using parameters tag to define what you need to generate: /paramters:parameters.xml, see here for details) Add this file into VStudio project;
Step 3: Start query SharePoint List data by using LINQ query such as:
var query= from c in EntityClassesDataContext.Contacts where !c.ListName.Equal(""); orderby c.FirstName select c;
The advantage of using LINQ is, they are all strongly typed, and you get all intellisense.
Reference: