日期:2014-05-18  浏览次数:20930 次

求问一下Entity SQL或者Linq To Entity如何实现这个Oracle SQL语句
select f.fund_code,f.fund_name ,nvl(fr.off_flag,'0') as off_flag ,nvl(fr.on_flag,'0') as on_flag ,to_char(fr.off_expiry_date,'YYYY-MM-DD') as off_expiry_date ,c.STOP_OPR_DATE as contract_expiry_date,
c.seat_no as seat_no ,remark from v_ns_fund f, ns_fund_right fr, cs_info c where f.fund_code = fr.fund_code(+) and c.hx_code(+) = fr.fund_code order by to_number(nvl(f.hs_code,'999999'))";

上面是Oracle的sql语句,怎么翻译到EF下面用,多谢了!

------解决方案--------------------
C# code

var query=from f in v_ns_fund.ToList()
          from fr in ns_fund_right.ToList()
          from c in cs_info.ToList()
          where f.fund_code == fr.fund_code && c.hx_code == fr.fund_code 
          orderby f.hs_code   //oracl 内 to_number(nvl(f.hs_code,'999999')) 是神马意思
          select new 
          {
             f.fund_code,f.fund_name ,// 后边自己写吧
          };

------解决方案--------------------
nvl函数,当数据库某字段为空时设置默认值