我目前检索所有页面和过滤掉未发布代码的,检查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