?
Solved

Linq .contains for ints

Posted on 2012-09-11
1
Medium Priority
?
417 Views
Last Modified: 2012-09-11
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
Comment
Question by:adskarcox
1 Comment
 

Accepted Solution

by:
adskarcox earned 0 total points
ID: 38386912
Looks like the .int equivalent is .equals
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question