Linq的Oracle SQL语句不起作用

时间:2013-07-11 17:27:57

标签: c# linq oracle

我有一个查询,我需要在SQL中转换它。一直在寻找这样做一段时间但没有什么是成功的 这是ORACLE查询

SELECT 
     DRKY AS REASON_CODE,
     DRDL01 AS DESCRIPTION
 FROM shema.SourceTable
WHERE drsy = '00'  AND DRDL01 IS NOT NULL AND (drrt = 'W4' OR drrt = 'W5') and NVL ( trim(DRKY), '000') = '801';

这是我的Linq查询,它不返回值

            var RJDEReasonCode = from a in JTable.SourceTable
                             where
                               a.DRSY.Equals( "00") &&
                               a.DRDL01 != null &&
                               (a.DRRT.Equals( "W4") ||
                               a.DRRT.Equals( "W5")) &&
                               a.DRKY.Equals( "801") // here is where the problem is  tried many things  but nothing has worked so far.
                             select new
                             {
                                 CATEGORY_CODE = a.DRRT,
                                 REASON_CODE = a.DRKY,
                                 DESCRIPTION = a.DRDL01
                             };

1 个答案:

答案 0 :(得分:3)

看起来您只需要修剪DRKY

a.DRKY.Trim() == "801"

或者可能:

a.DRKY != null && a.DRKY.Trim() == "801"

(我个人认为==字符串比较比使用Equals更简单,但是使用YMMV。)