C# 为什么可以';使用SqlFunctions在LinQ中将int转换为字符串?
为什么这C# 为什么可以';使用SqlFunctions在LinQ中将int转换为字符串?,c#,linq,entity-framework,sql-server-ce,C#,Linq,Entity Framework,Sql Server Ce,为什么这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])'
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/sqlce/C#
代码是一个int字段您应该使用
SqlceFunctions
而不是SqlFunctions
所以你的代码应该是
Groups.Where(x => SqlCeFunctions.StringConvert ((double?) x.Code)
.TrimStart() .StartsWith(txtSearch.Text))
.ToList();
名称空间:System.Data.Entity.SqlServerCompact 你能说得更具体些吗?什么是异常/错误?什么是异常/编译器错误?什么是组及其代码属性?代码是一个Int字段,组是一个实体列表