SP 2010: LINQ to SharePoint - What CAML lies behind my query?

Author: Tobias Zimmergren http://www.zimmergren.net | http://www.tozit.com | [@zimmergren](http://www.twitter.com/zimmergren) Introduction The two following questions are quite popular in my SharePoint 2010 developer training classes, so I ought to answer them right here. "What does LINQ to SharePoint really do?" "Can I see the CAML query generated by the LINQ to SharePoint query?" The answer is simple: Yes, you can see the results of your generated LINQ query by using the Log property of your DataContext object. What CAML lied behind my LINQ to SharePoint query? In order to…

Read More

SP 2010: List Joins & SPQuery enchancements!

Author: Tobias Zimmergren http://www.zimmergren.net | http://www.tozit.com | [@zimmergren](http://www.twitter.com/zimmergren) Introduction As per request by some of my readers who wanted information about how you can query SharePoint lists using joins in SharePoint 2010, here’s an introduction! With the introduction of relational lists in SharePoint 2010, they also introduced a new set of investments in how we can interact with our lists. We now have Projected fields, joins and relational integrity between parent and child lists. Projected Fields & Relational Integrity will be covered in an upcoming blog series. Joins With our…

Read More

U2U CAML Query Builder - New version out

I just read Karine Bosch’s blog where she posted some news on the U2U CAML Query Builder, so I just ought to get your attention in that direction. Check the detailed updates out in Karine’s blog: [http://www.u2u.info/Blogs/karine/Lists/Posts/Post.aspx?List=d35935e0-8c0e-4176-a7e8-2ee90b3c8e5a&ID=30](http://www.u2u.info/Blogs/karine/Lists/Posts/Post.aspx?List=d35935e0-8c0e-4176-a7e8-2ee90b3c8e5a&ID=30 "http://www.u2u.info/Blogs/karine/Lists/Posts/Post.aspx?List=d35935e0%2D8c0e%2D4176%2Da7e8%2D2ee90b3c8e5a&ID=30") Cheers…

Read More

How To: Easily construct your CAML queries with CAML Query Builder

This post is a mere followup to my previous minor posts on the subject of SPQuery and SharePoint queries located here. Basically this post will provide step-by-step instructions to construct your CAML (Collaborative Application Markup Language) queries using the U2U CALM Query Builder which you can find on the U2U Community Tools page. Prerequisites In order to be able to follow along with this step-by-step instructions you’ll need the following: U2U CAML Query Builder 2007 or later A site containing a Task List with some items - Some items with Status set to Completed Some items with Status set…

Read More

Introduction to SharePoint Queries

Prephase Recently I’ve been using SharePoint Queries more and more, not to say in my latest personal project: Zimmergren Forum WebPart. At times when I’ve been out at some clients to help them either refactor existing code or build new code, weather doing it myself of joining an existing SharePoint team – I always bump into things that could be solved using Queries instead of the way they’ve solved it using for- and foreach loops to go through entire lists with if-statements checking if that’s what they’re looking for. Example: Codenotusingqueries – Get all SPListItem objects that…

Read More

SPQuery returning all items

If you’ve ever used the SPQuery objects to get SPListItems from a SPList, and you didn’t get it to work because the query would return ALL items in the SPList, you might have used code similar to this: SPQuery postsQuery = new SPQuery(); postsQuery.Query = string.Format(     ""+        ""+           "" +        ""+        ""+           ""+              ""+              "{0}"+           ""+        ""+     "", threadID); SPList allPosts = SpecificForumData.GetPostList(); // Custom method to get the SPList object SPListItemCollection posts = allPosts.GetItems(postsQuery); I’ve always built my queries by hand (what better way to…

Read More

SharePoint Cross List Queries in a custom UserControl

Author: Tobias Zimmergren Url: http://www.zimmergren.net I got the question last week weather it’s possible to get items from all lists of gathered and displayed on one page. This is – like most things – possible in SharePoint without any greater efforts. With something called Queries we can use the object model to query SharePoint and get a result quite painlessly. To demonstrate a very simple example, I’ve created a very small usercontrol (for use with Jan Tielen’s SmartPart) that looks like this: This code will combine all the items in all of the TaskLists on the…

Read More