views:

61

answers:

2

I am trying to have the collection of order IDs be used in my where statement how come i can't get this to work?

List<int> orders   = new List<int>(){1,2,3,4,5};

DataTable dtTable1 = getOrders();
DataTable dtTable2 = getOrderDetails();
var results = from a in dtTable1.AsEnumerable()
              join b in dtTable2.AsEnumerable() on a.Field<int>("ID") equals b.Field<int>("ID")
              where orders.Contains(b.Field<int>("OrderID"))
              select a;
+1  A: 

Wild guess:

on a.Field<int>("ID") equals b.Field<int>("OrderID") 
David B
Nope notice i'm using an array of Int's to compare against the field in table b.where orders.Contains(b.Field<int>("OrderID"))
BlackTea
A: 

The syntax looks good to me. And since they're value types, I expect the comparisons to work fine. Are you sure you have the right columns selected for your specific data? Maybe you can tell us the values in your tables and what you're expecting to see.

Crispy