Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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.

Source: http://www.microsoft.com/download/en/details.aspx?id=17069

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: social.technet.microsoft.com/Forums/en-US/… –  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

 
discard

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.