I have a table schema like this:
MyTable columns:
- FirstCol: 1507, 1507, 1507,1507,1507
- SeconCol: 1508,1509,1510,1511,1512
I have a integer simple list of:
List<int> myList= new List<int>();
int a = 0;
int myId= 1507;
myList.Add(myId);
foreach (var item in myList)
{
a = item.myId;
myList.Add(a);
}
It's result come like this :
1507, 1508, 1509,1510,1511,1512(i am trying to get recursive query)
My second list of:
IEnumerable<Table> MyTable= table.SelectAll();
//myTable contains MyTableId, MyId, DeptId, UserId etc.
I just want to search if myTable's firstcol equals where ListmyList values. So here is my linq query with lambda expression.
MyTable= MyTable.Where(myList.Contains((int)MyTable.Select(p=>p.myId))).ToList();
I get "Unknown methor where(bool) of. How can i change my query?
Try this:-
var result = MyTable.Where(x => myList.Contains(x.FirstCol)).ToList();
You can't use where clause like that, check Where syntax.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.