Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何修剪Linq到SQL?_C#_Linq_Linq To Sql - Fatal编程技术网

C# 如何修剪Linq到SQL?

C# 如何修剪Linq到SQL?,c#,linq,linq-to-sql,C#,Linq,Linq To Sql,我有一张这样的桌子:(不能换这个) 有人能告诉我如何用Linq修剪前导零吗 我试着这样做: from t in table where (t.value.TrimStart('0')).Equals("33") select t 但它不起作用:“value”字段显然是一个字符串,因为它保留了前导零。我没有尝试过,但是在进行比较之前,您不能将值强制转换为整数吗?比如: from t in table where (t => Convert.ToInt32(t) == 33) select t

我有一张这样的桌子:(不能换这个)

有人能告诉我如何用Linq修剪前导零吗

我试着这样做:

from t in table
where  (t.value.TrimStart('0')).Equals("33")
select t

但它不起作用:“value”字段显然是一个字符串,因为它保留了前导零。我没有尝试过,但是在进行比较之前,您不能将值强制转换为整数吗?比如:

from t in table where (t => Convert.ToInt32(t) == 33) select t 从表中的t开始 其中(t=>Convert.ToInt32(t)==33) 选择t
如果需要将值保留为字符串,可以使用string.EndsWith(),但在匹配正确的“值”时可能会遇到问题

它不工作是因为您得到了一个不受支持的方法异常,还是实际的代码没有产生您想要的结果? from t in table where (t => Convert.ToInt32(t) == 33) select t