The documentation is useful and you'll be able to test the queries without problems
Well if you look at the DataTable you'll see that you have all the fields you need there to retrieve the SPListItem easily.
I have created an extension method, well two really... I love extension methods.
public static SPListItem GetListItemFromSiteData(this DataRow ItemRow, SPSite ParentSite) { using (SPWeb Web = ItemRow.GetWebSiteData(ParentSite)) { return Web.Lists[new Guid(ItemRow["ListId"].ToString())].GetItemById(Convert.ToInt32(ItemRow["ID"])); } } public static SPWeb GetWebSiteData(this DataRow ItemRow, SPSite ParentSite) { return ParentSite.OpenWeb(new Guid(ItemRow["WebId"].ToString())); }
Using these two you will be able to iterate through the collection of rows of the DataTable, select which elements need to be updated and update them.
I haven't tested how fast is this compared with bringing the items with a CAML query. Not having to create the SPListItemCollection could make this method faster and more convenient for some things... I'll give it a go.
No comments:
Post a Comment