开发者

How to get the latest item created by a specific user by CAML query

开发者 https://www.devze.com 2023-01-24 17:50 出处:网络
I am trying to get the most recent item created by a specific user by CAML query but it seems to return all the data created by everyone.

I am trying to get the most recent item created by a specific user by CAML query but it seems to return all the data created by everyone.

Help please.

Here's my code:

strin开发者_开发问答g lifestyleQuery = @"<Where><Eq><FieldRef Name='Author' /><Value Type='Text'>" + _id + @"</Value></Eq></Where>";


Try this:

SPQuery query = new SPQuery();
query.Query = @"<Where><Eq><FieldRef Name='Author' LookupId='TRUE' /><Value Type='Integer'>" + _id + @"</Value></Eq></Where><OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy>";
query.RowLimit = 1;
0

精彩评论

暂无评论...
验证码 换一张
取 消