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:
- Open up the SharePoint Management Shell and give the command
SPMETAL /web:<url of the web site> /code:<the name of the class file> - Once the file has been generated add the same to the project where it needs to be used
- We need to add a reference to the class "Microsoft.SharePoint.Linq"
- 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"
- We need to then create an object of the Data Context class created and use the same for CRUD operations
Comments
Post a Comment