Can I use LINQ with lists in sharepoint online? If so, can someone provide me with an example?
2 Answers
Yes, you can use it in SharePoint online
SharePoint 2010 includes the LINQ to SharePoint provider, which translates LINQ statements to CAML queries. LINQ is a standard query language and, when applied to SharePoint, it enables developers to query SharePoint lists without requiring them to learn the CAML syntax that is used internally by SharePoint.
Source: http://www.microsoft.com/download/en/details.aspx?id=17069
-
Yes, I've read the developer guide. I also tried spmetal, but as expected it did not work. I can't figure out how to write the query. Can you provide me with an example?– MortenFeb 2, 2012 at 9:13
-
Here is an example from the ms forums: social.technet.microsoft.com/Forums/en-US/… Feb 3, 2012 at 11:02
-
Thanks a lot, to the both of you. So far, I have tried the following: Create a site locally in my sharepoint 2010 developement environment. Use SPMetal to generate the entities from the lists. Export the lists and the webpart to my sharepoint online site. I was able to get it up and running, but I had to change something in my javascript. After deploying the webpart for the second time, I got the errormessage about running in a sandboxed solution– MortenFeb 6, 2012 at 10:55
-
-
FreeStyler, there's not alot of details in the errormessage, I forgot it and have been unable to reproduce. Anyway, I managed to run my webpart now. As mentioned, I used SPMetal to generate entities from the list in my local sharepoint developement environment. I then created the same lists in sharepoint online in a new site, and added the visual webpart solution to sharepoint online. I was hoping I could just export my local site as a solution (with webpart included), and import it into my sharepoint online site. But all attempts have failed, giving me a varierity of errormessages.– MortenFeb 6, 2012 at 14:19
Yes, We can use LINQ in SharePoint Online. I used it in a Visual web part which stores the information from the form to the list. Here are the steps to follow:
Create a ListContext File with the help of SPMetal
Now use the ListCotext file as the entity layer for the data saving and modification functionality