views:

29

answers:

0

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<T> because I have interfaces to my objects.

I've tried most things but for some reason I must run Cast<T> first and then ToList() which generates System.NullReferenceException. How do I solve this?

public IQueryable<IPhrase> GetPhrases() {  
    return (from r in _repository.All<Phrase>()
            select r).Cast<IPhrase>()  
}