2012-03-28 3 views
0

저는 NHibernate에 익숙하지 않으며 술어에 대해 DateTime 비교를 사용하려고 할 때 변환 오류의 원인을 추적하는 데 도움이되기를 기대하고 있습니다.NHibernate QueryOver 변환 오류 (DB2 날짜 유형)

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) 

.

답변

1

이 특정 iSeries 예외에 대한 경험은 상점 프로 시저 유형 ADO 명령에 대한 ADO.NET 명령 매개 변수 목록에 대한 매개 변수 (iDB2TypeParameter의)를 작성한 때였습니다. iDB2DbType.Date, iDB2DbType.Time 또는 iDB2DbType.TimeStamp와 같이 어떤 종류의 iDB2DbType을 사용해야하는지 명시 적으로 알려야했습니다. iSeries ADO 제공자는 .NET System.DateTime 유형에서 매개 변수를 작성할 때 사용할 세 가지 유형 중 어 @ 것을 알 수 없습니다.

new iDB2Parameter(parameterName, iDB2DbType.Date){ Value = myValue }; 
new iDB2Parameter(parameterName, iDB2DbType.Time){ Value = myValue }; 
new iDB2Parameter(parameterName, iDB2DbType.TimeStamp){ Value = myValue }; 

이 예제처럼 수동으로 매개 변수를 만들지 않고 대신 NHibernate를 사용한다는 사실을 알고 있습니다. 그래서, 나는 DB2/iSeries 용 NHibernate의 LINQ 제공자가이를 알고 있는지 확인합니다. 그것은 NHibernate에 대한 것이 아닙니다. DB2/iSeries를위한 좋은 ORM을 찾는 것이 거의 불가능하다는 것을 알았습니다.