• EF 筛选列包含NULL会报错


     当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改为空

  • 相关阅读:
    Flask_脚本
    数据库
    模板
    视图函数和视图类
    HTTP请求
    Flask路由注册
    初识Flask
    微信小程序之基础使用
    celery任务队列
    文件处理小结
  • 原文地址:https://www.cnblogs.com/kingvi/p/12810044.html
Copyright © 2020-2023  润新知