SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 0 down vote accepted

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.


share|improve this answer
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 '12 at 9:13
Here is an example from the ms forums:… – Anders Aune Feb 3 '12 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 '12 at 10:55
Could you post the error log/message in your above post? – Falak Mahmood Feb 6 '12 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 '12 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:

  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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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