- /// <summary>
- /// 按条件查询产品
- /// </summary>
- /// <param name="name"></param>
- /// <param name="type"></param>
- /// <param name="batch"></param>
- /// <returns></returns>
- public static List<product> SelectPro(string name, string type, string batch)
- {
- Expression<Func<product, bool>> expr1 = (name == "0") ? DynamicLinqExpressions.True<product>() : (p => p.prod_name.Contains(name));
- Expression<Func<product, bool>> expr2 = (type == "0") ? DynamicLinqExpressions.True<product>() : (p => p.prod_type.Contains(type));
- Expression<Func<product, bool>> expr3 = (batch == "0") ? DynamicLinqExpressions.True<product>() : (p => p.prod_batch.Contains(batch));
- List<product> result = DBHelper222.Context.product.Where<product>(DynamicLinqExpressions.And((DynamicLinqExpressions.And(expr1, expr2)),expr3).Compile()).ToList();
- return result;
- }
转载于:https://blog.51cto.com/doubleqian/674994