Does anyone know the solution for this?
If I'm querying items by SPSiteDataQuery I receive a DataTable with DataRow objects.
I could fetch the current version of an item and check if it ends with ".0" (indicating a major version).
If it isn't a major version, I could convert the DataRow to SPListItem and get the last published major version as SPListItem.
Else (if it is a major version) i can proceed with my DataRow object:
DataTable results = ...//get results from SPSiteDataQuery
foreach (DataRow row in results.Rows){
string version = (string)row["_UIVersionString"];
if (!version.EndsWith("0"))
{
string absUrl = (string)row["EncodedAbsUrl"];
SPListItem item = web.GetFile(absUrl).Item;
SPListItem newestItem = null;
foreach (SPListItem publishedMajorVersionItem in item.Versions)
{
if (publishedMajorVersionItem.Level == SPFileLevel.Published)
newestItem = publishedMajorVersionItem;
}
}
//proceed with DataRow object
CustomObject o = new CustomObject();
o.Title = (string)row["Title"];
}
What is missing is: how can I get a DataRow object from the SPListItem?
Or: is there another way to get the last major published version if I'm using SPSiteDataQuery without converting the DataRow to SPListItem?