in my db i have a table with column (string) containing the ID (key) of another table.
column string content is in the form of > 1,2,3 exc...
lets say i nave table "TABLEA":
NAME FIELDS
john 1
bob 1,2
i'm passing the "itemFilter" quary in order to find all items in the table that column "FIELDS" match one or more ID's:
var itemFilter = "1";
query = query.Where(c => c.TABLEA.FIELDS.Contains(itemFilter));
"itemFilter" needs to bring back results for both john and bob but this is not working properly.
i belive this quary creates "AND" relation but i need to get an "OR" relation in order to get all items that match one or mote ID's in the array.
how do i do that?
Loading
Iftikar HussainPosted Jul 31, 2013, 3:03 AM
Regards,
Iftikar
navePosted Jul 31, 2013, 2:56 AM
Try to change
var itemFilter = "1";
to
var itemFilter = "1,2";
in order to get both john and bob in the results. i get only bob.
any idea?
thanks
Iftikar HussainPosted Jul 31, 2013, 2:45 AM
It is working fine
try like this
var itemFilter = "1";
var result = query.Where(c => c.FIELDS.Contains(itemFilter)).ToList();
Regards,
Iftikar
navePosted Jul 31, 2013, 2:36 AM
when i change
var itemFilter = "1";
to
var itemFilter = "1,2"; (want to find all items that contain both 1 or 2 in the array)
i get only 1 result. needs to be 2 results (john, bob).
when i change to
var itemFilter = "1,3";
i get 0 results.
any idea?
thanks
Posted Jul 30, 2013, 3:56 PM
And it works fine.