像Linq中的运算符(对于整数) [英] Like operator in Linq(For integer)

查看:62
本文介绍了像Linq中的运算符(对于整数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linq中,我们对字符串使用like运算符

从ctx中的

In Linq we use the like operator for strings
i.e,

var query = from c in ctx.Customers
            where c.City.StartsWith("L") && c.City.Contains("n")
            select c;


是否有可能像linq一样对整数应用运算符.

请帮助我.


Is it Possible to apply like operator in linq for integers.

please help me.

推荐答案

除非将int转换为字符串,否则"like"运算符将无法使用:您不能在其中指定整数以7开头"或以23结尾"的术语-只是没有任何语法可以做到这一点.您可以只对所需的值进行比较,也可以使用模数运算符提取相关信息.

您要达到什么目的,以为您认为自己需要这个?
Unless you convert the int to a string, the "like" operator has nothing to work from: you can''t specify an integer in terms of "starts with a 7" or "ends with 23" - there just isn''t any syntax to do that. You could just use a comparison against the values you want, possibly using the modulus operator to extract relevant information.

What are you trying to achieve that you think you need this?


这篇关于像Linq中的运算符(对于整数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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