Search code examples
sharepointsharepoint-2010spquery

Sharepoint SPQuery problem


I'm trying to use GetItems() method on a SPList and I pass SPQuery to it. The problem is, it return all the items from my SPList instead of just the filtered ones. My query looks like this:

 <WHERE><Eq><FieldRef Name='Type' /><Value Type='Text'>Analysis</Value></Eq></WHERE>

Thye typye of the'Type' column is Single line of text, which i believe translates to Text in CAML. Then I just do the standard stuff:

SPQuery q = new SPQuery();
q.Query = CAMLQuery.ToString();
var filtered = _NoticeList.GetItems(q);

filtered.Count is 4 instead of 2... perhaps someone cann se whats wrong with this code


Solution

  • I think CAML is Case sensitive so it'd have to be:

    <Where><Eq><FieldRef Name='Type' /><Value Type='Text'>Analysis</Value></Eq></Where>
    

    Otherwise you could try renaming the 'Type' field, because it might be interpreted as an internal field.