1
而當學生們集合在內存中的樣本數據填充了以下工作序列運營商,我得到一個System.NotSupportedException
查詢數據庫時。我正在開發一個WindowsPhone 8項目。的LINQ到SQL - 不支持類型「System.String」
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();
爲什麼在數據庫查詢時會發生這種情況,我該如何解決這個問題?
我需要一個字符不是一個字符串。第一個建議返回一個字符串,並且'char.ToLower(student.FirstName [0])'仍然拋出一個'NotSupportedException'方法'Char ToLower(Char)'沒有支持到SQL的轉換。第二個建議不是如何實施擴展方法。 – Pantelis
@坦率地說,堅韌;使用第一個版本,並且在完成數據庫查詢後,將字符串長度爲1的字符數改爲char * **。 LINQ-to-SQL想要使用'string' –