Question

While the following works when the Students collection is populated from in memory sample data, I get a System.NotSupportedException when querying the database. I'm working on a WindowsPhone 8 project.

List<CustomGrouping<Student>> groupings =
    (from student in dataContext.Students
        orderby student.FirstName
        orderby student.LastName         
    group student by Char.ToLower(student.FirstName.First()) into grouping        
    select new CustomGrouping<Student>(
        grouping.Key, grouping.AsEnumerable())).ToList();

Why does it happen with the database query and how do I solve this?

Was it helpful?

Solution

student.FirstName.First() is not supported. Try:

student.FirstName.Substring(0, 1).ToLower()

or:

student.FirstName[0].ToLower()

instead

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top