1

Can I use LINQ with lists in sharepoint online? If so, can someone provide me with an example?

2 Answers 2

0

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

5
  • 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?
    – Morten
    Feb 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
    – Morten
    Feb 6, 2012 at 10:55
  • Could you post the error log/message in your above post? Feb 6, 2012 at 11:31
  • 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.
    – Morten
    Feb 6, 2012 at 14:19
0

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:

  1. Create a ListContext File with the help of SPMetal

  2. Now use the ListCotext file as the entity layer for the data saving and modification functionality

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.