SharePoint : How to check for null with a CAML Query?
Agree with Colin, and more often used condition are as following:
1. Null:
<Where><IsNull><FieldRef Name="CustomField" /></IsNull></Where>
2. Not Null:
<Where><IsNotNull><FieldRef Name="CustomField" /></IsNotNull></Where>
3. Equal:
<Where><Eq><FieldRef Name="CustomField" /><Value Type="Text">MatchValue</Value></Eq></Where>
4. Not Equal:
<Where><Neq><FieldRef Name="CustomField" /><Value Type="Text">MatchValue</Value></Neq></Where>
5. Greater Than:
<Where><Gt><FieldRef Name="CustomField" /><Value Type="Text">1</Value></Gt></Where>
6. Greater Than And Equal:
<Where><Geq><FieldRef Name="CustomField" /><Value Type="Text">1</Value></Geq></Where>
7. Lower Than:
<Where><Lt><FieldRef Name="CustomField" /><Value Type="Text">1</Value></Lt></Where>
8. Lower Than And Equal:
<Where><Leq><FieldRef Name="CustomField" /><Value Type="Text">1</Value></Leq></Where>
9 Begin With:
<Where><BeginsWith><FieldRef Name="CustomField" /><Value Type="Text">StartString</Value></BeginsWith></Where>
10: Contains:
<Where><Contains><FieldRef Name="CustomField" /><Value Type="Text">ContainString</Value></Contains></Where>
Note: More information please visit: http://msdn.microsoft.com/en-us/library/ms467521.aspx There is the fully Caml Query Schema.
Hope this can help you~
CAML has the IsNull operator,so the query would be:
query.Query = @"<Where><IsNull><FieldRef Name='MessageID' /></IsNull></Where>"
Needed an equivalent to String.IsNullOrEmpty(Description)
. Ended up with this:
<And>
<IsNotNull>
<FieldRef Name='Description' />
</IsNotNull>
<Neq>
<FieldRef Name='Description' />
<Value Type='Text'></Value>
</Neq>
</And>