LinqKit PredicateBuilder returns all or non rows

梦想与她 提交于 2019-11-29 07:16:33

The And extension-method does not modify the original predicate - it returns a new predicate representing the original predicate ANDed together with the specified predicate.

Effectively, your operations are not changing the predicate referred to by your pre variable, meaning you end up with either all or none of the records based on whether you initialized the original predicate to true or false.

Try:

    var pre = PredicateBuilder.True<MyEntity>();
    pre = pre.And(m => m.IsActive);

If you are planning toOR predicates together, remember to start off with a false initial predicate.

    var pre = PredicateBuilder.False<MyEntity>();
    pre = pre.Or(m => m.IsActive);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!