.net 拉姆达表达式 追加 条件判断 Expression<Func<T, bool>>

参考原文:

https://www.cnblogs.com/keitsi/p/5621136.html

http://m.bubuko.com/infodetail-465328.html

需要引用:LinqKit 

//定义追加的过滤变量
var searchWhere = PredicateBuilder.New<实体类>();

if (!string.IsNullOrWhiteSpace(custName))
     searchWhere = searchWhere.And(t => t.CustomerName.Contains(custName));
if (!string.IsNullOrWhiteSpace(carModel))
     searchWhere = searchWhere.And(t => t.CarType.Contains(carModel));
View Code

 

posted @ 2019-12-03 11:31  狼窝窝  阅读(777)  评论(0编辑  收藏  举报