I’m really glad that we have managed to get a really nice release of the SharePoint Extensions Lib, SPExLib, out. This brand new release (12.0.0.0) has significantly been improved since the first release a couple of weeks ago.
Keith Dahlby has made some really nice Linq extensions for SharePoint which is available in this release. These extensions are also IDisposable safe when using on SPWeb and SPSite collections.
By referencing the SPExLib.dll and include the namespaces you can easily write code like this (taken directly from one of my current projects):
1: SPList regions = web.Lists["Regions"];
2: regions.GetItems("<Where><Eq><FieldRef Name='Customer'/><Value Type='Lookup'>{0}</Value></Eq></Where>"
3: .FormatWith(lookupValue)
4: )
5: .ForEach<SPListItem>(
6: item => ddlRegion.Items.Add(new ListItem(item["Title"].ToString(), item.ID.ToString()))
7: );
As you can see the sample uses a number of extension methods; SPList.GetItems() can accept a CAML query directly, System.String has a FormatWith method, the SPListItemCollection has a ForEach method.
Download it and try it out, you will find yourself more productive!
Have a nice weekend.