Search code examples
c#searchintcomparecontain

Compare method for type int


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. enter image description here


Solution

  • 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());