You have to provide two objects:
a) a DataTable in which you have to find values
b) Dictionary with key as String (column name) and value as an array of strings (values which you are looking for)
As a result you can obtain the following output dictionaries:
a) Present dictionary – contains columns with the names and values you were looking for – the matched values.
b) Missing dictionary – contains the names of the columns and values which are missing.
c) Leftovers dictionary – contains the names of the columns and rest values except those which were missing or you were looking for.
d) Find confirmation dictionary – contains the names of columns and True or False values – True when all values from the array were found and False if any of it were missing.
Numbers, Cities, Countries, Elements
23, Szczecin, Poland, Iron
8987, Berlin, Germany, Polon
34, Prague, Czech, Hydrogen
231, New York, USA, Oxygen
11, Moscow, Russia, Mercury
1515, Shanghai, China, Chlorine
125, Tokyo, Japan, Iridium
Here are the data which we are looking for:
Elements: Mercury, Iron, Oxygen
Here is how our query dictionary is looking like:
Dictionary<string, string[]>(3) { { "Numbers", string[3] { "23", "34", "11" } }, { "Cities", string[2] { "Berlin", "Tokyo" } }, { "Elements", string[3] { "Mercury", "Iron", "oxygen" } } }
And here are our results:
a) Present dictionary (Present_dictionary)
Dictionary<string, string[]>(3) { { "Numbers", string[3] { "23", "34", "11" } }, { "Cities", string[2] { "Berlin", "Tokyo" } }, { "Elements", string[3] { "Mercury", "Iron", "Oxygen" } } }
b) Missing dictionary (Missing_dictionary)
Dictionary<string, string[]>(3) { { "Numbers", string[0] { } }, { "Cities", string[0] { } }, { "Elements", string[0] { } } }
c) Leftovers dictionary (Leftover_dictionary)
Dictionary<string, string[]>(3) { { "Numbers", string[4] { "8987", "231", "1515", "125" } }, { "Cities", string[5] { "Szczecin", "Prague", "New York", "Moscow", "Shanghai" } }, { "Elements", string[4] { "Polon", "Hydrogen", "Chlorine", "iridium" } } }
d) Find confirmation dictionary (Found_dictionary)
Dictionary<string, bool>(3) { { "Numbers", true }, { "Cities", true }, { "Elements", true } }
If we would modify our query with some values which are not in table:
Dictionary<string, string[]>(3) { { "Numbers", string[3] { "23", "34", "16" } }, { "Cities", string[2] { "Warsaw", "Tokyo" } }, { "Elements", string[3] { "Mercury", "Iron", "Oxygen" } } }
Then in b and c, we will get:
B’) Dictionary<string, string[]>(3) { { "Numbers", string[1] { "16" } }, { "Cities", string[1] { "Warsaw" } }, { "Elements", string[0] { } } }
C’) Dictionary<string, bool>(3) { { "Numbers", false }, { "Cities", false }, { "Elements", true } }
The step by step manual is available in the documentation in "Powersearch - one-page manual how to use"