Convert to list after Cast<T>
- by Timmie Sarjanen
Hi,
I need to convert an IQueryable to List(is it possible to convert to IList?). There had not been an problem if it was not that i need to Cast because I have interfaces to my objects.
I've tried most things but for some reason I must run Cast first and then ToList() which generates System.NullReferenceException. How do I solve this?
public IQueryable GetPhrases() {
return (from r in _repository.All<Phrase>()
select r).Cast<IPhrase()
}