• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 421
  • Last Modified:

Linq .contains for ints

Hello,

I've got a search form:

Last Name:  [lastNameTextBox]
ID:  [idTextBox]

I process this search for by starting with a base linq query:

var query = from u in db.users
                    select u;

Next, I see if the user entered something into the last name text box and if they did, I append the information to the base linq query:
                         
if (!string.IsNullOrEmpty(LastNameTextBox.Text))
{
      query = query.Where(t => t.LastName.Contains(LastNameTextBox.Text));
}

Open in new window


My problem is that I can't seem to get the part for the ID to work:

if (!string.IsNullOrEmpty(IDTextBox.Text))
{
      query = query.Where(t => t.ID.Contains(convert.toInt32(IDTextBox.Text)));
}

Open in new window


.Contains() doesn't seem to work, because I think .Contains() is for strings only.  Any idea how to get this to work?

Environment:
C#.NET 4.0
0
adskarcox
Asked:
adskarcox
1 Solution
 
adskarcoxAuthor Commented:
Looks like the .int equivalent is .equals
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now