Newbie Question - Sorry!

Feb 28, 2015 at 12:50 PM
Hi all, im pretty new to using linq2twitter and i have had a bit of a learning curve. There is some great guides and discussions that are extremely helpful and Joes blog to working with timelines has been really helpful to a newbie. I am having an issue and it will probably be a newbie error but cant get to the bottom of it. I am creating an app that queries ever 5 mins and reads through and counts hashtags, and serves this to a tcp client, all this is working but i need it only pick up the latest tweets in the last 5 mins, so im querying with sinceID but i then want to get the max ID and set this to the since ID so that it only reads from the last max..... so code look like this ....
ulong maxid, sinceid;

var statusTweets = from tweet in twitterContext.Status
                               where tweet.Type == StatusType.Mentions &&
                                       tweet.ScreenName == twitterAccountToDisplay &&
                                       tweet.IncludeContributorDetails == true &&
                                       tweet.Count == 10 &&
                                       tweet.SinceID == sinceid &&
                                       tweet.IncludeEntities == true &&
                                       tweet.IncludeUserEntities == true 
                                                                            
                               select tweet;

            maxid = statusTweets.Max(search => search.MaxID) -1;

            sinceid = maxid;
Im getting an error on maxid = statusTweets.Max(search => search.MaxID) -1; of "Expression of type 'System.UInt64' cannot be used for return type 'System.Object'"

Can anyone give me a pointer on this?

regards.
Mar 2, 2015 at 9:24 PM
Hi again,

So I have read the documentation and change the code above to assist as below. The first time this runs in a timed cycle it returns tweets and prints the MaxID, i then set this to the sinceID but on the second pass i get an error that the "since_id parameter is invalid"

Am i wrong that i shouldn't be capturing the Max ID and setting this to the since id so it only returns tweets after the last max?
 var statusTweets = from tweet in twitterContext.Status
                               where tweet.Type == StatusType.Mentions &&
                                       tweet.ScreenName == twitterAccountToDisplay &&
                                       tweet.IncludeContributorDetails == true &&
                                       tweet.Count == 10 &&
                                       tweet.SinceID == sinceid &&
                                       tweet.IncludeEntities == true &&
                                       tweet.IncludeUserEntities == true

                               select tweet;

            if (statusTweets != null)

            {
                    PrintTweets(statusTweets);
                    var terms1 = statusTweets.ToArray();
                    maxid = terms1.Max(search => search.MaxID) - 1;
                    sinceid = maxid;
                    string x = maxid.ToString();    
                    updateUI(x);
             }
Coordinator
Mar 4, 2015 at 3:27 AM
Hi,

I wrote a blog post, Working with Timelines with LINQ to Twitter, that might help.

@JoeMayo