我正在使用客户端对象模型来查询列表中的记录。它按唯一的标题过滤,所以我希望它只返回一条记录,但它会返回整个列表。
这是代码:
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;
这有什么问题?为什么它会返回整个列表?