I have a query that is working when using any CAML query builder, when in using it in c# for a SharePoint web part, it always returns no results.
using (SPWeb ThisWeb = ThisSite.OpenWeb())
{
IList<Tweet> Tweets = GetTweets(item["Mode"].ToString(), item["String"].ToString(), LastTweet, ThisSite);
SPList ThisList = ThisWeb.Lists.TryGetList(Variables.TwitterTweetList);
foreach (var tweet in Tweets)
{
SPListItemCollection itms = ThisList.GetItems(new SPQuery() { Query = @"<Where>" +
"<Eq>" +
"<FieldRef Name=""Title"" />" +
"<Value type=""Text"">" + tweet.tweetID.ToString() + "</Value>" +
"</Eq>" +
"</Where>"
});
if (itms.Count == 0)
{
// add the tweet to 'ThisList'
}
}
}
Stepping into the code, you'll see tweet.tweetID.ToString() is "337958304577892353"
When running this code, it return ZERO items.
When running the query in U2U builder or any other CAML query it returns 1 (2, 3, 4, etc if the code is ran more then once).
Query ran in U2U builder:
<Query>
<Where>
<Eq>
<FieldRef Name="Title" />
<Value type="Text">"337958304577892353"</Value>
</Eq>
</Where>
</Query>
(Yes, when doing CAML in SharePoint, you drop the tags... I have 3 other queries that work just fine.. it's just this one.)