如何参数化linq查询?
我有一个数据结构,它是一个哈希表列表,如下所示:如何参数化linq查询?,linq,Linq,我有一个数据结构,它是一个哈希表列表,如下所示: List<Hashtable> lh = new List<Hashtable>(); 有没有办法参数化where子句?比如: var where_clause = where h["foo"] == "bar"; var query = from h in lh where_clause select h; 取决于你到底想完成什么,但你可以: Func<List<Hashtable>, bool&g
List<Hashtable> lh = new List<Hashtable>();
有没有办法参数化where子句?比如:
var where_clause = where h["foo"] == "bar";
var query = from h in lh where_clause select h;
取决于你到底想完成什么,但你可以:
Func<List<Hashtable>, bool> where_clause = h => h["foo"] == "bar";
List<Hashtable> lh = new List<Hashtable>();
var query = lh.Where(where_clause);
Func其中_子句=h=>h[“foo”]=“bar”;
列表lh=新列表();
var query=lh.Where(Where_子句);
取决于你到底想完成什么,但你可以:
Func<List<Hashtable>, bool> where_clause = h => h["foo"] == "bar";
List<Hashtable> lh = new List<Hashtable>();
var query = lh.Where(where_clause);
Func其中_子句=h=>h[“foo”]=“bar”;
列表lh=新列表();
var query=lh.Where(Where_子句);
相当圆滑。但是我们可以将“h[“foo”]=“bar””本身参数化为字符串吗?当然可以。查找有关动态LINQ的信息。从ScottGu的博文开始:相当圆滑。但是我们可以将“h[“foo”]=“bar””本身参数化为字符串吗?当然可以。查找有关动态LINQ的信息。从ScottGu的博客文章开始: