LINQ的int值的字符串 [英] Linq int to string
本文介绍了LINQ的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到实体不能识别方法System.String的ToString()方法,这种方法不能被翻译成店前pression
的
推荐答案
LINQ实体不支持的功能,许多转化为服务器托管的SQL。
Linq to Entities does not support as many conversion of functions to server hosted sql.
的ToString(任何东西)就是其中之一。
ToString (on anything) is one of them
下面的支持的功能的列表
这已经问过的堆栈溢出专门<一href="http://stackoverflow.com/questions/1066760/problem-with-converting-int-to-string-in-linq-to-entities">asking如何将一个int转换为字符串
This has been asked before on Stack overflow specifically asking how to convert an int to a string
这篇关于LINQ的int值的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文