0

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

matt99
  • 869
  • 2
  • 8
  • 19

1 Answers1

2

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.

int32
  • 1,687
  • 1
  • 10
  • 6
  • yup, was the problem, figured it out but i couldn't post a solution myself earlier, thanks ('Type' isn't originaly named that, I just renamed it so that it would be in english here, sorry for mix up) – matt99 Aug 04 '11 at 07:28
  • Just FYI to avoid confusion later on. This handler helps a lot for writing these queries. https://gist.github.com/trgraglia/4672176 – Anthony Graglia Mar 27 '14 at 09:03