Reputation: 685
I am using the client object model to query a record in a list. It filters by the Title which is unique so I would expect it to only return one record but it is returning the entire list.
Here's the code:
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;
What's wrong with this? Why is it returning the entire list?
Upvotes: 3
Views: 1809
Reputation: 2683
You're missing the query node around the .
It should look like this
<View>
<Query>
<Where>
<!-- -->
</Where>
</Query>
</View>
CAML is sometimes more than strict! Just give it a try.
Thorsten
Upvotes: 3