title: In Linq-to-Nhibernate, has anyone managed to use .Contains in a where clause and also NHibernate.Linq.ToFuture() in the same query? (NH 3.x)
body: <p>I always get a "System.Collections.Generic.KeyNotFoundException" that says "The given key was not present in the dictionary" whenever I try to use .Contains and the ToFuture() method in one query.</p>
  
  <p>Imagine the DBObject contains a bunch of properties with one of them being an integer "ID"</p>
  
  <pre><code>List&lt;int&gt; test = new List&lt;int&gt;();
          test.Add(1557);
          test.Add(1558);
          test.Add(1559);
  
          IEnumerable&lt;DBObject&gt; test2 = getLinqQuerySomehow&lt;DBObject&gt;().Where(x =&gt; test.Contains(x.ID)).ToFuture();
          List&lt;DBObject&gt; results = test2.ToList();
  </code></pre>
  
  <p>Can anyone reproduce this? Does anyone know of another way besides contains() to make Linq-to-Nhibernate use the SQL IN clause for the ints in my test list while also using ToFuture()?</p>
  
  <p>Stacktrace:</p>
  
  <blockquote>
  
    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
    at NHibernate.Param.NamedParameterSpecification.SetEffectiveType(QueryParameters queryParameters) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Param\NamedParameterSpecification.cs:line 70
    at NHibernate.Param.ParametersBackTrackExtensions.ResetEffectiveExpectedType(IEnumerable`1 parameterSpecs, QueryParameters queryParameters) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Param\ParametersBackTrackExtensions.cs:line 48
    at NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.ResetEffectiveExpectedType(IEnumerable`1 parameterSpecs, QueryParameters queryParameters) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Loader\QueryLoader.cs:line 428
    at NHibernate.Loader.Loader.CreateSqlCommand(QueryParameters queryParameters, ISessionImplementor session) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Loader\Loader.cs:line 1649
    at NHibernate.Impl.MultiQueryImpl.AggregateQueriesInformation() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\MultiQueryImpl.cs:line 641
    at NHibernate.Impl.MultiQueryImpl.get_Parameters() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\MultiQueryImpl.cs:line 774
    at NHibernate.Impl.MultiQueryImpl.CreateCombinedQueryParameters() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\MultiQueryImpl.cs:line 754
     at NHibernate.Impl.MultiQueryImpl.List() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\MultiQueryImpl.cs:line 400
     at NHibernate.Impl.FutureQueryBatch.GetResultsFrom(IMultiQuery multiApproach) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\FutureQueryBatch.cs:line 24
     at NHibernate.Impl.FutureBatch`2.GetResults() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\FutureBatch.cs:line 73
    at NHibernate.Impl.FutureBatch`2.get_Results() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\FutureBatch.cs:line 29
    at NHibernate.Impl.FutureBatch`2.GetCurrentResult[TResult](Int32 currentIndex) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\FutureBatch.cs:line 79
    at NHibernate.Impl.FutureBatch`2.c__DisplayClass4`1.b__3() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\FutureBatch.cs:line 63
    at NHibernate.Impl.DelayedEnumerator`1.d__0.MoveNext() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\DelayedEnumerator.cs:line 26
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    at TestProject1.UnitTest1.TestMethod1() in C:\checkout\Library Projects\BaseSystemCore\TestProject1\UnitTest1.cs:line 94
  
  </blockquote>