BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News LINQ-to-Twitter, Another LINQ Provider

LINQ-to-Twitter, Another LINQ Provider

Leia em Português

This item in japanese

Bookmarks

Mehfuz Hossain, a Microsoft MVP, has created a LINQ-to-Twitter provider. This is yet another example demonstrating that LINQ is not a framework to access just data in a database but it can be used with all sorts of objects, including tweets.

LINQ-to-Twitter makes use of Yedda, a C#/.NET wrapper for the Twitter API. For Twitter methods like Status, User, Friends, Yedda returns the result as XML, JSON, RSS or ATOM.

LINQ-to-Twitter takes the Yedda returned XML and converts it into queriable objects using LINQExtender, a free library which provides basic functionality for creating LINQ providers. There are two steps involved in creating a provider using LINQExtender, according to Hossain:

First you have to define a query object by implementing IQueryObject and then you have made a Query<T> successor and override few methods.

A query example looks like this:

TwitterContext context = new TwitterConext();

var query = from twit in context
             where twit.Username == "myuser"
                && twit.Password == "mypass"
                && twit.Timeline == Timeline.Friends
             orderby twit.LastUpdated descending
             select twit;

Yet another LINQ provider based on LINQExtender is LINQ.Flickr for querying, adding, deleting, commenting, etc. photos on Flickr. LINQExtender can be used under MIT license.

Useful links: LINQ-to-Twitter source code (ZIP), LinqExtender, Using LinqExtender Tutorial.

Rate this Article

Adoption
Style

BT