我目前檢索所有頁面和過濾掉未發佈代碼的,檢查DateTime.Now
是否比這更小:CAML查詢只檢索SharePoint 2007發佈的頁面?
static readonly DateTime IMMEDIATE_PUBLISH = new DateTime(1900, 1, 1);
public static DateTime PublicationDate(this SPListItem item)
{
// get start publish date
PublishingPage page = item.Publishing();
if (page != null)
{
bool isPublished = (page.ListItem.File != null)
? (page.ListItem.File.Level == SPFileLevel.Published)
: true;
bool isApproved = (page.ListItem.ModerationInformation != null)
? (page.ListItem.ModerationInformation.Status == SPModerationStatusType.Approved)
: true;
if (isPublished && isApproved && (DateTime.Now < page.EndDate))
{
return page.StartDate == IMMEDIATE_PUBLISH ? page.CreatedDate : page.StartDate;
}
return DateTime.MaxValue;
}
// not a scheduled item. treat as published
return DateTime.MinValue;
}
將是等效的CAML查詢什麼,讓我的SharePoint不從數據庫中拉出不必要的項目?
根據此示例(http://www.stum.de/2008/03/13/caml-queries /),無論答案如何,這將是一個可怕的褻瀆,並提醒爲什麼Sharepoint是惡魔的化身。 – Juliet 2010-07-02 07:12:23
CAML.Net http://camldotnet.codeplex.com/有所幫助。 – skolima 2010-07-02 10:32:38