Closed
Description
A query (IQueryable) worked in version 4.0.4 but has exception in 5.2.2:
'query.ToList()' threw an exception of type 'System.NotSupportedException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233067
HelpLink: null
InnerException: null
Message: "query ( query ( select_from ( from ( range ( . _0 RolePrivileges ) a ) ) ( select a ) ) ( where ( and ( == ( . a AccessTypeName ) ( : p12 ) ) ( or ( == ( : p13 ) true ) ( == ( . ( . param002 Role ) Id ) ( : p14 ) ) ) ) ) )"
Source: "NHibernate"
StackTrace: " at NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.GetClassName(IASTNode querySource)\r\n at NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.Process(IASTNode tree)\r\n at NHibernate.Hql.Ast.ANTLR.AstPolymorphicProcessor.Process()\r\n at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)\r\n at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters)\r\n at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)\r\n at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression)\r\n at NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, IQuery& query)\r\n at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)\r\n at NHib
ernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)\r\n at Remotion.Linq.QueryableBase`1.GetEnumerator()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)"
Can be reproduced by adding the following test to WhereSubqueryTests
[Test(Description = "GH-2471")]
public void TimeSheetsWithStringContainsSubQueryWithAsQueryableAfterWhere()
{
var query = (from timesheet in db.Timesheets
where timesheet.Entries.Where(e => e.Comments != null).AsQueryable().Any(e => e.Comments.Contains("testing"))
select timesheet).ToList();
Assert.That(query.Count, Is.EqualTo(2));
}