[英]PredicateBuilder is still true even after adding explicit false statement
I have the following statement. 我有以下声明。
var search = PredicateBuilder.True<SomeType>();
search.And(f => false);
// Still the "search" variable value is: {f => true}.
At first, I was trying an expression; 起初,我正在尝试一种表达方式; nothing succeeded, so I tried this "false" instead.
没有成功,因此我尝试使用此“ false”。 No matter what I did, it's still the same.
不管我做什么,都还是一样。 What is happening?
怎么了?
PredicateBuilder
methods don't mutate the expression (they couldn't, as expression trees are immutable) - you need to use the return value: PredicateBuilder
方法不会更改表达式(因为表达式树是不可变的,因此无法更改)-您需要使用返回值:
var search = PredicateBuilder.True<SomeType>();
search = search.And(f => false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.