Using LINQLINQ in SharePoint is an effective and efficient way to query data. With SPMetal, you can prepare a SharePoint list for LINQ. The following describes how to prepare your list and create an application using LINQ. 1. Open the command line (run as administrator ). 2. navigate to c: \ Program Files \ Common Files \ Microsoft Shared \ web server extensions \ 14 \ binand enter the following command (ensure that your server name is replaced by your spmetal.exe/web: http: // <servername>/code: SPEntityModel. cs/language: csharp
3. The SPMetal command tool will create the C # file SPEntityModel. cs. You can use it to execute the LINQ query on the SharePoint list model in an application (SPMetal mainly translates all the lists in the site into Entity models ). 4. Enable VS as an administrator. 5. Create a blank SharePoint project MyFirstSPLinqProject, click OK, and deploy the project as a field solution. 6. Right-click the project to add an existing item and find the created SPEntityModel. cs. 7. Right-click the project to add a new item, select Web Part, and name it MySPLinqWebPart. Click Add. 8. Right-click reference and select Add reference. Click Browse and navigate to the c: \ Program Files \ Common Files \ Microsoft Shared \ web server extensions \ 14 \ ISAPI. select Microsoft. SharePoint. Linq. dll and click OK. 9. Right-click MySPLinqWebPart. cs to view the code. 10. modify code: 11. Modify the. webpart file code: 12. Deploy the solution after completion. 13. Add this Web Part. 14. Click Get Lists to obtain the target customers and types of the list. Local Machine:
PS: This article and the previous blog posts.