如何使用通配符搜索移动数字来获取数据C#中的bigint / int数字? [英] How to get data with wildcard search for mobilenumber which bigint/int number in C#?

查看:94
本文介绍了如何使用通配符搜索移动数字来获取数据C#中的bigint / int数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据数字搜索数据,其中包含linq或lamdaexperssion中的搜索号码

数据低于

Id名称ContactNumber

1 A 9043484888
2 B 8938938983


select * from contactDetails其中数字如'%484%'





我尝试过:



 select * from contactDetails其中数字如'%484%'
搜索值484

var result = details.Where(e => e.ContactNumber.ToString()。包含(searchvalue))。ToList

解决方案

始终将电话号码存储在字符串数据类型中:它们不是数字,因为您无法对它们进行任何数学运算:什么是你的电话号码加上我的电话号码?它可能是什么?



此外,电话号码不仅仅是数字: +44(0777)777 7777 是一种有效的电话号码格式 - +44表示它是英国号码,(0777)是英国境内的区号,这些空间使人们更容易阅读。您可以将数据值中的任何一个存储起来!



当您将它们存储为字符串时,可以对它们使用LIKE,但不能使用数字。

I want to search data based on number whihc is contains search numbers in linq or lamdaexperssion

data is below

Id Name ContactNumber

1  A    9043484888
2  B    8938938983


select * from contactDetails where number like '%484%'



What I have tried:

select * from contactDetails where number like '%484%'
Search value 484

var result = details.Where(e=>e.ContactNumber.ToString().Contains(searchvalue)).ToList

解决方案

Always store phone numbers in string datatypes: they aren't numbers because you can't do any maths with them: what is your phone number plus my phone number? What would it possibly be?

In addition, phone numbers aren't just digits: +44 (0777) 777 7777 is a valid phone number format - the +44 indicates it's a UK number, the (0777) is an area code within the UK, and the spaces make it easier for humans to read. You can;t store any of that in a numeric value!

When you store them as strings, you can use LIKE on them, but not with numbers.


这篇关于如何使用通配符搜索移动数字来获取数据C#中的bigint / int数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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