【问题标题】:Sharepoint Client Object Model query filter not workingSharepoint 客户端对象模型查询过滤器不起作用
【发布时间】:2012-01-14 01:21:02
【问题描述】:

我正在使用客户端对象模型来查询列表中的记录。它按唯一的标题过滤,所以我希望它只返回一条记录,但它会返回整个列表。

代码如下:

FieldLookupValue result = new FieldLookupValue();
List list = web.Lists.GetByTitle(lookupSourceList);
var query = new CamlQuery
                {
                   ViewXml =
                        string.Format(
                          "<View><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>{0}</Value></Eq></Where></View>",
                           lookupValue)
                };
var ls = list.GetItems(query);
ctx.Load(ls, li => li);
ctx.ExecuteQuery();
if (ls.Count == 1)
{
    result.LookupId = ls[0].Id;
}

return result;

这有什么问题?为什么会返回整个列表?

【问题讨论】:

    标签: c# .net sharepoint sharepoint-clientobject


    【解决方案1】:

    您缺少 . 周围的查询节点。

    应该是这样的

    <View>
      <Query>
        <Where>
        <!-- -->
        </Where>
      </Query>
    </View>
    

    CAML 有时不仅严格!试试看吧。

    索斯滕

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-04
      • 1970-01-01
      • 2016-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多