CAML query on GetItems doesn’t filter the content

So basically today I am creating a SPQuery object to filter list items. The filtering code for list goes like this

SPQuery qry = new SPQuery();
//.. generate the query here
SPListItemCollection listItemsCollection = list.GetItems(qry);

The code doesn’t give any error, but somehow the CAML query doesn’t work. Kind of misleading isn’t it 🙂

So it turns out that the CAML that I generate is wrong, I use <query> tag that makes it ignore all of my query entirely (somehow it doesn’t give me any error at all).

<Geq><FieldRef Name="Expires" />
<Value IncludeTimeValue="TRUE" Type="DateTime">2011-05-06T21:00:21Z</Value></Geq>
<IsNull><FieldRef Name="Expires" /></IsNull>
<OrderBy><FieldRef Name="Created" Ascending="False" /></OrderBy></Query>

Just remove the query tag and the GetItems should work

<Where><Or><IsNull><FieldRef Name="Expires" /></IsNull>
<Geq><FieldRef Name="Expires" /><Value Type="DateTime">2011-05-06T14:22:09</Value></Geq></Or>
<OrderBy><FieldRef Ascending="FALSE" Name="Created" /></OrderBy>