开发者

SPQuery calculated fields filter does not work in SharePoint 2007/2010

开发者 https://www.devze.com 2023-03-06 14:12 出处:网络
I have a calculated field in my list and I am trying to use filter on this field. For some reason, the following query always returns all items instead of a filtered item co开发者_StackOverflow中文版l

I have a calculated field in my list and I am trying to use filter on this field. For some reason, the following query always returns all items instead of a filtered item co开发者_StackOverflow中文版llection:

var spQuery = new SPQuery
    {
        Query = @"<Where><Geq><FieldRef Name='Score' /><Value Type='Calculated'>10000</Value></Geq></Where><OrderBy><FieldRef Name='Modified' Ascending='True' /></OrderBy>",
        RowLimit = 200,
        ViewFields = @"<FieldRef Name='Username' />"
    };

var spList = web.Lists["Users"];

var spListItemCollection = spList.GetItems(spQuery);


try using

spQuery.ViewFieldsOnly = true;


Remove the query element from your SPQuery. See syntax here


Try removing ViewFields section (to get all columns, also those that are needed for calculation) or set SPQUery.IncludeMandatoryColumns

0

精彩评论

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