我必须在 linq 查询连接语句中将数据类型从 long 转换为 string。 例如
from t1 in table1
join t2 in table2 on new {t1.field1, t1.field2} equals new {t2.field1, t2.field2}
select new {t1.field1,t2.field1 all columns}
t1.field2是long类型,t2.field2是string类型。 当我放置 ToString 方法时,它会抛出异常。 异常信息
LINQ to Entities 无法识别“System.String ToString()”方法,并且无法将此方法转换为存储表达式。
我们将不胜感激。
最佳答案
SqlFunctions.StringConvert((double) t1.field2)
关于c# - Linq to Sql 中的数据类型转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14252717/