I have a variable List< Dictionary < string, object >> as follows.
private static List<Dictionary<string, object>> testData = new List<Dictionary<string, object>>(100); // Just Sample data for understanding. for (int i = 0; i < 100; i++) { var test = new Dictionary<string, object> { { "aaa", "aaa" + i % 4 }, { "bbb", "bbb" + i % 4 }, { "ccc", "ccc" + i % 4 }, { "ddd", "ddd" + i % 4 }, { "eee", "eee" + i % 4 }, { "fff", "fff" + i % 4 }, { "ggg", "ggg" + i % 4 }, { "hhh", "hhh" + i % 4 }, { "iii", "iii" + i % 4 } }; testData.Add(test); }
I want to find the list of keys, the value in the dictionary and return List< Dictionary < string, object >> containing the passed searchPattern.
Dictionary<string, object> searchPattern = new Dictionary<string, object>(); searchPattern .Add("aaa", "aaa4"); searchPattern .Add("eee", "eee2"); searchPattern .Add("fff", "fff1"); searchPattern .Add("ddd", "ddd3"); public List<Dictionary<string, object>> SearchList(List<Dictionary<string, object>> testData, Dictionary<string, object> searchPattern) { List<Dictionary<string, object>> result; // Search the list. return result; }
Any other search suggestions are also appreciated. Thank you very much!