This project has moved and is read-only. For the latest updates, please go here.

First N tweets that do not have StatusID in List<string>

May 1, 2013 at 12:54 AM
Edited May 1, 2013 at 12:58 AM
I was hoping to be able to select "the first N tweets that do not have StatusID in <List>" like I do in Entity Framework. I tried the code below but it does not appear to have an effect (the tweet with StatusID 329377395314393089 still appears):
var ignoreStatusID = new List<string>{ 

var srch =
    (from search in twitterCtx.Search
        where search.Type == SearchType.Search &&
            search.Query == "#f150"
            && search.IncludeEntities == true
            && search.Statuses.Any(s => !ignoreStatusID.Contains(s.StatusID))
            && search.Count == 5
        select search)
Maybe I messed up my .Any() (it wouldn't be the first time), or maybe there's another way to accomplish what I'm after?

If not, would I be correct in saying that my only alternative would be to drop any matching items after the query (in which case I'll select N*2 and trim to N afterwards...while hoping I don't have to re-select again if I trim too many)?
May 1, 2013 at 1:12 AM
The only valid operators on filter is equality, which sets the parameter to that value. We're querying a REST endpoint, so normal SQL doesn't apply here. You can visit the docs to see what filter parameters are available, which correspond to what the Twitter API exposes. With Search, you can include advanced operators as part of the Query. Also, Twitter Search doesn't work like a normal search engine, as they don't return some items. Sometimes it's useful to build your query with Twitter's Search to make sure you're getting what you want and then write the code.

For any filters that aren't available. Do a broader LINQ to Twitter search to get what you need and then do a LINQ to Objects query on the results that LINQ to Twitter pulls down for you.

May 1, 2013 at 4:16 PM
Cool, thanks. That was pretty much what i figured based on my limited knowledge of the Twitter API in the background...but i wanted to make sure.