I want to do the following but the only issue is that my input query is int not string and also I am searching from my RoomID which is also an integer and not a string. Let me simplify it, instead of _context.Customers.Name, I am comparing from _context.Room.Id which is an int type. This is an obligation and I have to do this. Guys ignore the .Select(Mapper.Map<>) Method, the primary focus is the int problem. I'd appreciate some help.
Asked
Active
Viewed 127 times
-6

Afnan Makhdoom
- 654
- 1
- 8
- 20
-
9`bool result = source.ToString.Contains(toFind.ToString());`? – Dmitry Bychenko Jul 13 '17 at 12:23
-
try using a regex? – David McEleney Jul 13 '17 at 12:25
-
3As an instructor once told me, "If you're not doing math on them, they aren't numbers" (Don't use ints if you want strings) – Mark Peters Jul 13 '17 at 12:35
2 Answers
3
One way to solve it is to convert the integers to string and do a contain.
Ex.
var needle = 234;
var haystack = 79234826;
var contains = haystack.ToString().Contains(needle.ToString());

ZarX
- 1,096
- 9
- 17
2
If you want to search as if both int
s are string
s, just let them be string
s:
int source = 79234826;
int toFind = 234;
bool found = source.ToString().Contains(toFind.ToString());

Dmitry Bychenko
- 180,369
- 20
- 160
- 215
-
-
@Sajeetharan: I'm sorry for the typo; Thank you for the pointing out. – Dmitry Bychenko Jul 13 '17 at 12:28