Convert to list after Cast<T>

Posted by Timmie Sarjanen on Stack Overflow See other posts from Stack Overflow or by Timmie Sarjanen
Published on 2010-03-25T22:06:36Z Indexed on 2010/03/26 0:13 UTC
Read the original article Hit count: 647

Filed under:
|
|

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>()
}

© Stack Overflow or respective owner

Related posts about iqueryable

Related posts about tolist