0

The Title is a little bit complicating. The Question here is easy:

If got a CheckBoxList. In this List you are allowed to do multiple choice. I put every chosen value from the Checkboxlist into a list because i need it for my where clause. So i have:

List<int> queueIDList = new List<int>();

Short version of my LINQ:

var reports = from t in tickets 
              where t.queue_id == every value in queueIDList 
              select t.ticketnumber;

So how do i have to write it when i want every ticketnumber from DB which is the same like in the queueIDList? For better knowing - in the CheckBoxList u can chose different Queues, at least u have to chose 1 (null is not allowed). I added the ID's of the chosen Queues to a list and now i want to have every ticketnumber from DB where the queueID equals with the values from the queueIDList.

I think the answer is easy but i'm really stuck with my mind.

Thanks for every help!

Dave Stockinger
  • 139
  • 2
  • 18
  • Think this article might be helpfull http://stackoverflow.com/questions/857973/linq-to-entities-sql-in-clause – Bernard Jun 25 '14 at 08:20

1 Answers1

2

You can just use Contains:

var reports = from t in tickets 
          where queueIDList.Contains(t.queue_id)
          select t.ticketnumber;
Jamiec
  • 133,658
  • 13
  • 134
  • 193