Last month I posted about the execution of a CAML querystring using the SPQuery class. Here at U2U we are currently doing an interesting project constructing the infrastructure to set up a social network on top SharePoint (see http://del.icio.us). For the UI, we of course use the smartpart (the latest version) of Jan. Jan also has created a generic data access layer to access the content of SharePoint lists. Karine is heavily involved into CAML and takes care of the display of the data in the user controls. Now, one of the things you can do is feed the results of the execution of a CAML query directly into an ADO.NET DataTable. That is nice since you then can start databinding with DataGrids, DataList and the other server controls.
SPGlobalAdmin = sharePointAdmin = new SPGlobalAdmin();
SPVirtualServer vServer =
sharePointAdmin.OpenVirtualServer(new Uri("your server"));
SPSite site = vServer.Sites["Team Web Site"];
SPWeb web = site.OpenWeb();
SPList trainersList = web.Lists["U2U Trainers"];
SPQuery query = new SPQuery(trainersList.Views["All Items"]);
string caml = "" +
"Patrick Tisseghem";
query.Query = caml;
SPListItemCollection results = trainersList.GetItems(query);
Now comes the nice thing! The SPListItemCollection has a method called GetDataTable() returning a nice ADO.NET DataTable you can then process.
return results.GetDataTable();
By the way, the forthcoming book of Scott Hillier ' Advanced SharePoint Services Solutions ' has a complete chapter on CAML.