Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何参数化linq查询?_Linq - Fatal编程技术网

如何参数化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的博客文章开始: