In Linq-to-Nhibernate, did anyone manage to use .Contains in the where clause, as well as NHibernate.Linq.ToFuture () in the same query? (NH 3.8)

I always get a "System.Collections.Generic.KeyNotFoundException" which says: "This key was not present in the dictionary" whenever I try to use .Contains and the ToFuture () method in the same request.

Imagine a DBObject contains a bunch of properties, one of which is an integer "ID"

List<int> test = new List<int>(); test.Add(1557); test.Add(1558); test.Add(1559); IEnumerable<DBObject> test2 = getLinqQuerySomehow<DBObject>().Where(x => test.Contains(x.ID)).ToFuture(); List<DBObject> results = test2.ToList(); 

Can anyone reproduce this? Does anyone know a way other than contains () so that Linq-to-Nhibernate uses the SQL IN clause for int in my test list, as well as using ToFuture ()?

Stacktrace:

in System.Collections.Generic.Dictionary`2.get_Item (TKey key) in NHibernate.Param.NamedParameterSpecification.SetEffectiveType (QueryParameters queryParameters) in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Param \ Namecarameter line 70 in NHibernate.Param.ParametersBackTrackExtensions.ResetEffectiveExpectedType (IEnumerable`1 parameterSpecs, QueryParameters queryParameters) in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Param \ ParametersBackTrackExt.qt.qtqckTrackHext ANTLR.Loader.QueryLoader.ResetEffectiveExpectedType (IEnumerable`1 parameterSpecs, QueryParameters queryParameters) in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Hql \ Ast \ ANTLR \ Loader \ QuerynoLoader.Name 42Loader.QueryLoader. .Loader.CreateSqlCommand (QueryParameters queryParameters, ISessionImplementor session) in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Loader \ Loader.cs: line 1649 in NHibernate.Impl.MultiQueryImpl.AggregateQueriesInformation d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ MultiQueryImpl.cs: line 641 in NHibernate.Impl.MultiQueryImpl.get_Parameters () in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ MultiQueryImpl.cs: line 774 in NHibernate.Impl.MultiQueryImpl.CreateCombinedQueryParameters () in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ MultiQueryImpl.cs: line 754 in NHibernate.Impl.plpl ) in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ MultiQueryImpl.cs: line 400 in NHibernate.Impl.FutureQueryBatch.GetResultsFrom (IMultiQuery multiApproach) in d: \ CSharp \ NH \ NH \ nhibern \ NHibernate \ Impl \ FutureQueryBatch.cs: line 24 in NHibernate.Impl.FutureBatch`2.GetResults () in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ FutureBatch.cs: line 73 in NHibernate. Impl.FutureBatch`2.get_Results () in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ FutureBatch.cs: line 29 in NHibernate.Impl.FutureBatch`2.GetCurrentResult [TResult] (Int32 currentIn dex) in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ FutureBatch.cs: line 79 in NHibernate.Impl.FutureBatch`2.c__DisplayClass4`1.b__3 () in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ FutureBatch.cs: line 63 in NHibernate.Impl.DelayedEnumerator`1.d__0.MoveNext () in d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Impl \ DelayedEnumerator. cs: line 26 in System.Collections.Generic.List`1..ctor (collection IEnumerable`1) in System.Linq.Enumerable.ToList [TSource] (source IEnumerable`1) in TestProject1.UnitTest1.TestMethod1 () in C : \ checkout \ Library projects \ BaseSystemCore \ TestProject1 \ UnitTest1.cs: line 94
+4
source share
1 answer

This is mistake. I found it in the Nhibernate tracker:

https://nhibernate.jira.com/browse/NH-2897

Edit: Must be fixed in NH 4.0.

+2
source

Source: https://habr.com/ru/post/1389185/


All Articles