DB2日期类型上的NHibernate查询转换错误
我是NHibernate的新手,我希望我能找到一些帮助来追踪转换错误的来源,当我尝试对谓词使用日期时间比较时DB2日期类型上的NHibernate查询转换错误,db2,queryover,Db2,Queryover,我是NHibernate的新手,我希望我能找到一些帮助来追踪转换错误的来源,当我尝试对谓词使用日期时间比较时 return _session.QueryOver<ShipmentSegment>() .Where(ss => ss.SegmentOrigin == selOrig) // Whenever I add the predicate for the SegmentDate below
return _session.QueryOver<ShipmentSegment>()
.Where(ss => ss.SegmentOrigin == selOrig)
// Whenever I add the predicate for the SegmentDate below
// I receive a conversion error
.And(ss => ss.SegmentDate == selDate)
.List<ShipmentSegment>();
内部异常
NHibernate.Exceptions.GenericADOException was unhandled by user code
Message=could not execute query
[ SELECT this_.ajpro# as ajpro1_28_0_, this_.ajleg# as ajleg2_28_0_, this_.ajpu# as ajpu3_28_0_, this_.ajlorig as ajlorig28_0_, this_.ajldest as ajldest28_0_, this_.segdate as segdate28_0_, this_.ajldptwin as ajldptwin28_0_, this_.ajlfrtype as ajlfrtype28_0_, this_.ajlfrdest as ajlfrdest28_0_, this_.ajtpmfst# as ajtpmfst10_28_0_, this_.ajspplan as ajspplan28_0_, this_.ajhload as ajhload28_0_ FROM go52cst.tstshprte this_ WHERE this_.ajlorig = @p0 and this_.segdate = @p1 ]
Name:cp0 - Value:WIC Name:cp1 - Value:3/28/2012 12:00:00 AM
Message=A conversion error occurred.
Source=IBM.Data.DB2.iSeries
ErrorCode=-2147467259
MessageCode=111
MessageDetails=Parameter: 2.
SqlState=""
StackTrace:
- at IBM.Data.DB2.iSeries.iDB2Exception.throwDcException(MpDcErrorInfo
mpEI, MPConnection conn)
- at IBM.Data.DB2.iSeries.iDB2Command.openCursor()
- at IBM.Data.DB2.iSeries.iDB2Command.ExecuteDbDataReader(CommandBehavior
behavior)
- at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
- at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
- at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection,
ISessionImplementor session)
- at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
- at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
session, QueryParameters queryParameters, Boolean returnProxies)
- at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
我非常感谢能为我指明正确方向的任何东西。我处理这个特定iSeries异常的经验来自我为存储过程类型ADO命令的ADO.NET命令参数列表创建参数(iDB2TypeParameter)时。我必须明确说明要使用哪种iDB2DbType:iDB2DbType.Date、iDB2DbType.Time或iDB2DbType.TimeStamp。当您从.NET System.DateTime类型创建参数时,iSeries ADO提供程序可能不知道要使用三种类型中的哪一种
new iDB2Parameter(parameterName, iDB2DbType.Date){ Value = myValue };
new iDB2Parameter(parameterName, iDB2DbType.Time){ Value = myValue };
new iDB2Parameter(parameterName, iDB2DbType.TimeStamp){ Value = myValue };
我意识到您不是像本例那样手动创建参数,而是使用NHibernate。因此,我要确保NHibernate的用于DB2/iSeries的LINQ提供程序知道这一点。这并不反对NHibernate,我只是发现几乎不可能为DB2/iSeries找到好的、可靠的ORM