masterfy

 

SqlException :Case 表达式只能嵌套到 10 层。

from a in MM_XXZX
        where a.CJRID == 1 && (a.DJLX == 0 || a.DJLX == 1 || a.DJLX == 5 || a.DJLX == 6 || a.DJLX == 7)
        orderby a.DJLX
        select new
        {
         XXLXMC = a.DJLX == 0 ? "检修计划" : (a.DJLX == 1 ? "检修任务单" : (a.DJLX == 2 ? "备件入库单" : (a.DJLX == 3 ? "备件出库单" : "备件计划"))),
         BM = a.BM,
         MS = a.MS,
         ZTMC =
          (a.ZT == 0 && a.DJLX == 0 ? "新建" : (a.ZT == 1 && a.DJLX == 0 ? "车间审批" : (a.ZT == 2 && a.DJLX == 0 ? "分厂审批" : (a.ZT == 3 && a.DJLX == 0 ? "完成" :
          (a.ZT == 0 && a.DJLX == 1 ? "新建" : (a.ZT == 1 && a.DJLX == 1 ? "待验收" : (a.ZT == 2 && a.DJLX == 1 ? "已验收" : (a.ZT == 3 && a.DJLX == 1 ? "待检修" :
          (a.ZT == 0 && a.DJLX == 5 ? "新建" : (a.ZT == 1 && a.DJLX == 5 ? "保管员审批" : (a.ZT == 2 && a.DJLX == 5 ? "已完成" : "过期"))))))))))),

         JSRXM = a.JSRXM
        }

 

将SQL存储过程转换用LINQ语句来写,结果因为CASE WHEN太长,居然报错:“SqlException :Case 表达式只能嵌套到 10 层。”还没找到好的解决办法!

posted on 2009-09-18 15:57  masterfy  阅读(1556)  评论(1编辑  收藏  举报

导航