Reputation: 67195
Can anyone tell me why the following code doesn't work?
IQueryable query = from pr in Repository.Query<ProviderRanking>()
orderby pr.ProviderRankingFlags.Any(), pr.TimestampUtc
select pr;
int count = query.Count();
IEnumerable<ProviderRanking> reviews = query.ToList();
The last two lines produce the errors:
'System.Linq.IQueryable' does not contain a definition for 'Count' and no extension method 'Count' accepting a first argument of type 'System.Linq.IQueryable' could be found (are you missing a using directive or an assembly reference?)
And:
'System.Linq.IQueryable' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'System.Linq.IQueryable' could be found (are you missing a using directive or an assembly reference?)
I was thinking that would work.
Upvotes: 0
Views: 719
Reputation: 887433
All LINQ methods (except Cast
and OfType
) extend generic collection interfaces.
You need to declare your variable as the generic IQueryable<T>
interface.
(or just use var
to infer that automatically.)
Upvotes: 3