简体   繁体   English

CAML查询获取具有最近创建日期的元素

[英]CAML Query get elements with most recent created date

I'm trying to get the elements with the most new created date using CAML query in sharepoint 2007. 我正在尝试使用SharePoint 2007中的CAML查询获取具有最新创建日期的元素。

I can do it using: 我可以使用:

"<OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy><RowLimit>1</RowLimit>"

To get the most recent date and then use other CAML query to get the elements with that date. 要获取最新日期,然后使用其他CAML查询来获取具有该日期的元素。

But, theres no other way to do it in one consult? 但是,没有其他方法可以一次咨询吗?

If you're looking for a specific date (eg : all the news that were created five years ago, but you don't know the magic number five) I would do the same, you can always limit the viewfields in your query to limit the fields that are retrieved (already well stripped with rowlimit=1). 如果您要查找特定的日期(例如:五年前创建的所有新闻,但您不知道魔术数字5)我也会这样做,则可以始终将查询中的视域限制为检索的字段(已经很好地用rowlimit = 1剥离了)。

There might be a way with groupby to get something similar or you can get the last x items order by date (if you know that for example, no more than x items are created per specific date) and do some post processing in Linq, but at first sight, you're on the good track. groupby可能会提供类似的方法,或者您可以按日期获得最后x个项目的订单(例如,如果您知道每个特定日期最多创建x个项目),并在Linq中进行一些后期处理,乍一看,您步入正轨。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM