Linq conversion

iqueryable, linq

Solution

as long as q.code is a string this should work: note that it is not creating an anonymous object, just the string is being selected.

    public IList<string> FindCodesByCountry(string country)
    {
        var query = from q in session.Linq<Store>()
                    where q.Country == country
                    orderby q.Code
                    select q.Code;

        return query.ToList();
    }

Problem

I am using the following code to return an IList: ``` public IList<string> FindCodesByCountry(string country) { var query = from q in session.Linq<Store>() where q.Country == country orderby q.Code select new {q.Code}; return (IList<string>) query.ToList(); } ``` However I keep getting this error: Unable to cast object of type 'System.Collections.Generic.List`1[<>f__AnonymousType0`1[System.String]]' to type 'System.Collections.Generic.IList`1[System.String]'. What I am supposed to return here?

Original source