Linq int 到字符串 [英] Linq int to string

查看:29
本文介绍了Linq int 到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 int 转换为字符串?以下方法均无效:

how do I cast and int into a string? None of the following do works:

from s in ctx.Services
    where s.Code.ToString().StartsWith("1")
    select s

from s in ctx.Services
    where Convert.ToString(s.Code).StartsWith("1")
    select s

from s in ctx.Services
    where ((string)s.Code).ToString().StartsWith("1")
    select s

编辑

我得到的错误是:

LINQ to Entities 无法识别方法 'System.String ToString()' 方法,并且该方法无法转换为存储表达式

推荐答案

Linq to Entities 不支持将函数转换为服务器托管的 sql.

Linq to Entities does not support as many conversion of functions to server hosted sql.

ToString(任何东西)就是其中之一

ToString (on anything) is one of them

这是支持的功能列表

这已经在 Stack Overflow 上专门问过了 询问如何将int转换为字符串

This has been asked before on Stack overflow specifically asking how to convert an int to a string

这篇关于Linq int 到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆