
LINQ to Twitter is a 3rd party LINQ Provider for the
Twitter micro-blogging service. It uses standard LINQ syntax for queries and includes method calls for changes via the
Twitter API.
ExampleYou can try LINQ to Twitter, even if you don't have a twitter account. The following query returns a list of tweets from the public timeline:
var twitterCtx = new TwitterContext();
var publicTweets =
from tweet in twitterCtx.Status
where tweet.Type == StatusType.Public
select tweet;
publicTweets.ToList().ForEach(
tweet => Console.WriteLine(
"User Name: {0}, Tweet: {1}",
tweet.User.Name,
tweet.Text));
From a coding experience perspective, the
TwitterContext type is analogous to
DataContext (LINQ to SQL) or
ObjectContext (LINQ to Entities). You use the
TwitterContext instance,
twitterCtx, to access
IQueryable<T> tweet categories. In the example above the
Status will give you the ability to query Status tweets.
Each tweet category has a
Type property for the type of tweets you want to get back. For example, Status tweets can be made for Public, Friend, or User timelines. Each tweet category has a type enum to help you figure out what is available. The example above uses
StatusType.Public to get Public Status tweets.
Just like other LINQ providers, you get an
IQueryable<T> back from the query. You can see how to materialize the query by invoking the
ToList operator. Just like other LINQ providers, LINQ to Twitter does deferred execution, so operators such as
ToList and
ToArray or statements such as
for and
foreach loops will cause the query to execute and make the actual call to Twitter.
For the latest news, follow
Joe Mayo on Twitter.
NuGet
In addition to being able to download from this site, you can also automatically install LINQ to Twitter into your Visual Studio projects via
NuGet; Here's how:
A Gentle Introduction to NuGet.
Samples
LINQ to Twitter Samples contains example code for using LINQ to Twitter with various .NET technologies.
Who is Using LINQ to Twitter?
Services, Sites, and Software that Use LINQ to Twitter
Available Feature Set
See
Making API Calls.
Follow Joe on Twitter