如何拼接Expression查询条件
1个回答
展开全部
转换下,大概如下:
var expression = Expression.Equal(Expression.Constant(1), Expression.Constant(1));
var parameterExpression = Expression.Parameter(typeof(Model.PM_PickStore), "p");
var propertyExpression = Expression.Property(parameterExpression, "DevID");
if (PlanNo == "") { expression = Expression.AndAlso(expression, Expression.Equal(propertyExpression, Expression.Constant(1)));}
if (PlanNo == "") { expression = Expression.AndAlso(expression, Expression.Equal(propertyExpression, Expression.Constant(2))); }
if (PlanNo == "") { expression = Expression.AndAlso(expression, Expression.Equal(propertyExpression, Expression.Constant(3))); }
var expression = Expression.Equal(Expression.Constant(1), Expression.Constant(1));
var parameterExpression = Expression.Parameter(typeof(Model.PM_PickStore), "p");
var propertyExpression = Expression.Property(parameterExpression, "DevID");
if (PlanNo == "") { expression = Expression.AndAlso(expression, Expression.Equal(propertyExpression, Expression.Constant(1)));}
if (PlanNo == "") { expression = Expression.AndAlso(expression, Expression.Equal(propertyExpression, Expression.Constant(2))); }
if (PlanNo == "") { expression = Expression.AndAlso(expression, Expression.Equal(propertyExpression, Expression.Constant(3))); }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询