当PlanNO 为空时,我们在EF查询筛选PlanNO列时,会报错
Expression<Func<DeliveryPlan, bool>> expr = PredicateExtensionses.True<DeliveryPlan>(); //动态拼接查询 //静态类的使用步骤 expr.And(c => c.IsDel == 1); if (!kname.IsEmpty())//出货计划单号查询 这里PlanNO { expr = expr.And(c => c.PlanNO.ToUpper().Contains(kname)); } if (!number.IsEmpty())//制单日期查询 { expr = expr.And(c => c.MakeDate >= Convert.ToDateTime(number)); } if (!numbers.IsEmpty()) //制单日期查询 { expr = expr.And(c => c.MakeDate <= Convert.ToDateTime(numbers)); } if (!idesd.IsEmpty()) //Isdel的默认值 { expr = expr.And(c => c.IsDel == idesd.AsInt()); } if (!numes.IsEmpty()) //下拉列表值 { expr = expr.And(c => c.IsAudit == numes.AsInt()); } if (!numvves.IsEmpty()) { expr = expr.And(c => c.Achieve == numvves.AsInt()); } var qury = getpagelistdata.GetPageList<XTAPP.Models.DeliveryPlan, object>(page, pagesize, out totalcount, expr.Compile(), c => c.ID); //查询到集合数据
--
解决方法可以把PlanNO的NULL改为空