Have you heard, there is this thing called LINQ, it’s all the rage these days. ;) I think everyone has at least one post about LINQ on their blog, so here is my contribution, with a SharePoint twist of course.
Using LINQ to query and display all list titles of a given SharePoint site.
Microsoft.SharePoint.SPSite _site = new Microsoft.SharePoint.SPSite("http://spdev");
Microsoft.SharePoint.SPWeb _web = _site.AllWebs[0];
var _allLists = from Microsoft.SharePoint.SPList _list in _web.Lists select _list;
foreach (var _spList in _allLists)
{
MessageBox.Show(_spList.Title);
}
There is another approach for using LINQ to query SharePoint and that is to use a custom LINQ provider like the LINQ to SharePoint provider over at CodePlex. I havent tried this out yet but it looks like an interesting provider.