日期:2014-05-17  浏览次数:20561 次

不晓得是oracle的错还是entityframework的错
C# code
string querySql = "select xtpz.xtpz_id,xtpz.pzxdm,xtpz.pzxmc,xtpz.xtpzfl,xtpz.kjlx,xtpz.pzxcszfw,xtpz.pzxcsz,xtpz.pzxmrcsz,xtpz.qyzt,xtpz.fwlx,xtpz.xjsfgl,xtpz.xjsfck" +
                ",xtpz.zd_guid,xtpz.glyfl,xtpz.xzqy_dm,xtpz.bzts" + ",sjyz.xtpzsjyz_id,sjyz.yzbz,sjyz.zxzsl,sjyz.zdzsl,sjyz.sfbt"
                + " from xt_xtpz xtpz " +
                                "left join XT_XTPZSJYZ sjyz on  xtpz.xtpz_id=sjyz.xtpz_id  " +
             "where xtpz.GLYFL=@GLYFL and trim(xtpz.ZD_GUID)=@ZD_GUID and xtpz.XZQY_DM=@XZQY_DM and xtpz.XJSFGL='0' and xtpz.XTPZFL=@XTPZFL and xtpz.QYZT='1'";

            ObjectParameter[] para = new ObjectParameter[4];
            ObjectParameter p1 = new ObjectParameter("GLYFL", typeof(System.Int32)); p1.Value = glyFl_Code;
            ObjectParameter p2 = new ObjectParameter("ZD_GUID", typeof(System.String)); p2.Value = zd_guid;
            ObjectParameter p3 = new ObjectParameter("XZQY_DM", typeof(System.String)); p3.Value = xzqy_dm;
            ObjectParameter p4 = new ObjectParameter("XTPZFL", typeof(System.Int64)); p4.Value = xtpz_fl;
            para[0] = p1; para[1] = p2; para[2] = p3; para[3] = p4;
            IEnumerable<ViewShareConfig> dataList = db.ExecuteStoreQuery<ViewShareConfig>(querySql, para);


IEnumerable<ViewShareConfig> dataList = db.ExecuteStoreQuery<ViewShareConfig>(querySql, para);
报错:值不在预期的范围内。

------解决方案--------------------
值不在预期的范围内

这个很明显是 数据库的提示,而非EF的提示,只是EF直接throw的数据库的异常


ps:有关这玩意,首先就是下断点,然后在vs2010的IntelliTrace里看最终执行语句到底是啥?话说vs的IntelliTrace是个不错的功能,虽然有点耗内存,虽然默认设置把调试信息丢在c盘让c盘莫名其妙就没空间,不过总体上这是个不错的功能
------解决方案--------------------
把querySql最终生存的SQL语句到查询分析器里面执行就知道原因了,很多时候不需要直接执行就能看出错误