Steps to use LINQ in SharePoint

In order to use LINQ in SharePoint, firstly we need to create a Data Context class. The steps to be followed are as follows:

  1. Open up the SharePoint Management Shell and give the command
    SPMETAL /web:<url of the web site> /code:<the name of the class file>
  2. Once the file has been generated add the same to the project where it needs to be used
  3. We need to add a reference to the class "Microsoft.SharePoint.Linq"
  4. In the Visual Web Part class where we need to use the LINQ we need to add a reference to the "Microsoft.SharePoint.Linq" and "System.Linq"
  5. We need to then create an object of the Data Context class created and use the same for CRUD operations

Comments

Popular posts from this blog

jQuery Basics

What is the difference between a Page Layout and Master Page in SharePoint?

Accessing data from SharePoint 2010 to an ASP.NET application