我有一个List< Dictionary < string, object >>
变量如下。
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);
}
我想在 Dictionary 中搜索键、值的列表并返回List< Dictionary < string, object >>
包含我传递的 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;
}
任何其他搜索建议也表示赞赏。非常感谢!!