"You must set Type" Error

Aug 4, 2011 at 10:23 PM

I have the following code:

TwitterContext ctx = new TwitterContext(auth);
Account account = ctx.Account.SingleOrDefault();

Which throws this error:

You must set Type.  Parameter name: Type 
at LinqToTwitter.TwitterQueryProvider.Execute[TResult](Expression expression)    
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source) 

Am I not implementing it correctly?  I feel like I'm overlooking something really simply, but I believe this worked in the past.

Aug 4, 2011 at 10:33 PM

Hi Marc,

This is a LINQ to Twitter idiom where you must specify the type for each entity.  For consistency, this idiom follows for all entities.  The alternative design would have been to have dozens of unique entities and I felt like the Twitter API was so large and that this would make it more approachable.  Account is an entity with mulitple query types. The docs, Managing Accounts, show you how to specify the type.  There are also examples in the downloadable code.


Aug 5, 2011 at 3:33 AM

Ok, that makes sense.  Thanks for the quick response!