为什么这个 Linq
不起作用?
Groups.Where(x => SqlFunctions.StringConvert((double?)x.Code)
.Trim().StartsWith(txtSearch.Text))
.ToList();
错误
The specified method 'System.String StringConvert(System.Nullable`1[System.Double])' on the type 'System.Data.Entity.SqlServer.SqlFunctions' cannot be translated into a LINQ to Entities store expression.
我正在使用 EF6/SQL CE/C#
Code 是一个 int 字段
最佳答案
您应该使用SqlceFunctions
而不是SqlFunctions
所以你的代码应该是
Groups.Where(x => SqlCeFunctions.StringConvert ((double?) x.Code)
.TrimStart() .StartsWith(txtSearch.Text))
.ToList();
命名空间:System.Data.Entity.SqlServerCompact;
关于c# - 为什么无法在 LinQ 中使用 SqlFunctions 将 int 转换为 string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20371972/