In my current stack where I use NH 2.1.2 and the contrib linq
provider (and fluent) it works fine in this situation. I am in the
process of upgrading to NH3 with the included Linq provider and faced
this problem.
my query is:
return Storage.Context<Dossier>()
.Where(x => x.TaakCode == aktieCode &&
(x.TimestampLaatsteWijziging >=
obsoleteFrom) &&
(x.DatumLaatsteBetaling >= obsoleteFrom))
.OrderBy(x => x.AgendaDatum)
.Take(count)
.ToList()
.Cast<IDossier>();
I use the list to force the execution.
the sql generated is like: select first 33 from tdossiers dossier0_
where dossier0_.taakkode1=? and dossier0_.lts_wijzig>=? and
dossier0_.ltsdatum>=? order by dossier0_.agenda asc
I observed here that there are only 3 parameters and the take 33 is
part of the sql with a logical outofrange exception when trying to get
index 3 (see below)
The exception is: NHibernate.Exceptions.GenericADOException: could not
execute query
Stacktrace
IBM.Data.Informix.IfxParameterCollection.RangeCheck(Int32 index)
IBM.Data.Informix.IfxParameterCollection.GetParameter(Int32 index)
System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item(Int32
index)
NHibernate.Driver.DriverBase.ExpandQueryParameters(IDbCommand cmd,
SqlString sqlString) in d:\CSharp\NH\nhibernate\src\NHibernate\Driver
\DriverBase.cs: line 222
NHibernate.AdoNet.AbstractBatcher.ExpandQueryParameters(IDbCommand
cmd, SqlString sqlString) in d:\CSharp\NH\nhibernate\src\NHibernate
\AdoNet\AbstractBatcher.cs: line 227
NHibernate.Loader.Loader.PrepareQueryCommand(QueryParameters
queryParameters, Boolean scroll, ISessionImplementor session) in d:
\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 1185
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies) in d:\CSharp\NH
\nhibernate\src\NHibernate\Loader\Loader.cs: line 399
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
session, QueryParameters queryParameters, Boolean returnProxies) in d:
\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs: line 236
NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src
\NHibernate\Loader\Loader.cs: line 1665
NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src
\NHibernate\Loader\Loader.cs: line 1674
NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor
session, QueryParameters queryParameters) in d:\CSharp\NH\nhibernate
\src\NHibernate\Loader\Loader.cs: line 1589
NHibernate.Loader.Loader.List(ISessionImplementor session,
QueryParameters queryParameters, ISet`1 querySpaces, IType[]
resultTypes) in d:\CSharp\NH\nhibernate\src\NHibernate\Loader
\Loader.cs: line 1583
NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor
session, QueryParameters queryParameters) in d:\CSharp\NH\nhibernate
\src\NHibernate\Hql\Ast\ANTLR\Loader\QueryLoader.cs: line 298
NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor
session, QueryParameters queryParameters) in d:\CSharp\NH\nhibernate
\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs: line 110
NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters
queryParameters, ISessionImplementor session, IList results) in d:
\CSharp\NH\nhibernate\src\NHibernate\Engine\Query\HQLQueryPlan.cs:
line 105
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression,
QueryParameters queryParameters, IList results) in d:\CSharp\NH
\nhibernate\src\NHibernate\Impl\SessionImpl.cs: line 658
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression,
QueryParameters parameters) in d:\CSharp\NH\nhibernate\src\NHibernate
\Impl\SessionImpl.cs: line 634
NHibernate.Impl.ExpressionQueryImpl.List() in d:\CSharp\NH\nhibernate
\src\NHibernate\Impl\ExpressionQueryImpl.cs: line 63
NHibernate.Linq.NhQueryProvider.ExecuteQuery(NhLinqExpression
nhLinqExpression, IQuery query, NhLinqExpression nhQuery) in d:\CSharp
\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 78
NHibernate.Linq.NhQueryProvider.Execute(Expression expression) in d:
\CSharp\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 27
NHibernate.Linq.NhQueryProvider.Execute[TResult](Expression
expression) in d:\CSharp\NH\nhibernate\src\NHibernate\Linq
\NhQueryProvider.cs: line 102
GetEnumerator()
ctor(IEnumerable`1 collection)
System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
logging
System.IndexOutOfRangeException: Invalid index 3 for this
IfxParameterCollection with Count=3.
at IBM.Data.Informix.IfxParameterCollection.RangeCheck(Int32 index)
at IBM.Data.Informix.IfxParameterCollection.GetParameter(Int32
index)
at
System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item(Int32
index)
at NHibernate.Driver.DriverBase.ExpandQueryParameters(IDbCommand
cmd, SqlString sqlString) in d:\CSharp\NH\nhibernate\src\NHibernate
\Driver\DriverBase.cs:line 222
at
NHibernate.AdoNet.AbstractBatcher.ExpandQueryParameters(IDbCommand
cmd, SqlString sqlString) in d:\CSharp\NH\nhibernate\src\NHibernate
\AdoNet\AbstractBatcher.cs:line 227
at NHibernate.Loader.Loader.PrepareQueryCommand(QueryParameters
queryParameters, Boolean scroll, ISessionImplementor session) in d:
\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs:line 1185
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies) in d:\CSharp\NH
\nhibernate\src\NHibernate\Loader\Loader.cs:line 399
at
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
session, QueryParameters queryParameters, Boolean returnProxies) in d:
\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs:line 236
at NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src
\NHibernate\Loader\Loader.cs:line 1665
3013 [Agent: adapter run thread for test 'TestGetDossiersOpAktieCode'
with id '27f9d1cc-00ec-4692-a778-640c7bf90d28'] WARN
NHibernate.Util.ADOExceptionReporter (null) -
System.IndexOutOfRangeException: Invalid index 3 for this
IfxParameterCollection with Count=3.
at IBM.Data.Informix.IfxParameterCollection.RangeCheck(Int32 index)
at IBM.Data.Informix.IfxParameterCollection.GetParameter(Int32
index)
at
System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item(Int32
index)
at NHibernate.Driver.DriverBase.ExpandQueryParameters(IDbCommand
cmd, SqlString sqlString) in d:\CSharp\NH\nhibernate\src\NHibernate
\Driver\DriverBase.cs:line 222
at
NHibernate.AdoNet.AbstractBatcher.ExpandQueryParameters(IDbCommand
cmd, SqlString sqlString) in d:\CSharp\NH\nhibernate\src\NHibernate
\AdoNet\AbstractBatcher.cs:line 227
at NHibernate.Loader.Loader.PrepareQueryCommand(QueryParameters
queryParameters, Boolean scroll, ISessionImplementor session) in d:
\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs:line 1185
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies) in d:\CSharp\NH
\nhibernate\src\NHibernate\Loader\Loader.cs:line 399
at
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
session, QueryParameters queryParameters, Boolean returnProxies) in d:
\CSharp\NH\nhibernate\src\NHibernate\Loader\Loader.cs:line 236
at NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters) in d:\CSharp\NH\nhibernate\src
\NHibernate\Loader\Loader.cs:line 1665
3014 [Agent: adapter run thread for test 'TestGetDossiersOpAktieCode'
with id '27f9d1cc-00ec-4692-a778-640c7bf90d28'] ERROR
NHibernate.Util.ADOExceptionReporter (null) - Invalid index 3 for this
IfxParameterCollection with Count=3.
3015 [Agent: adapter run thread for test 'TestGetDossiersOpAktieCode'
with id '27f9d1cc-00ec-4692-a778-640c7bf90d28'] DEBUG
NHibernate.Util.ADOExceptionReporter (null) - could not execute query
On 14 nov, 14:28, Diego Mijelshon <[email protected]> wrote:
> I'm using NH 2.1.2 with Informix and the contrib Linq provider; Take works
> fine for me.
> What version, dialect and driver are you using? What does your complete
> query look like?
>
> Diego
>
>
>
>
>
>
>
> On Tue, Nov 9, 2010 at 08:07, Erik <[email protected]> wrote:
> > It looks like a bug. I have a linq query resulting in sql with 3
> > parameters that works fine but when I add a take(10) I get an range
> > exception.
>
> > System.IndexOutOfRangeException: Invalid index 3 for this
> > IfxParameterCollection with Count=3.
>
> > The sql is like: select first 10 from ......
>
> > I think that the 10 is directly injected in the sql string but also
> > handled as a parameter in one place but not part of the
> > parametercollection
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]
> > >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.