OfType with a where clause fails with a NotSupportedException

Description

Stack trace is:
System.NotSupportedException : Specified method is not supported.
at NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.GetClassName(IASTNode querySource) in d:\Source\NHibernate\nhibernate\src\NHibernate\Hql\Ast\ANTLR\PolymorphicQuerySourceDetector.cs: line 61
at NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.Process(IASTNode tree) in d:\Source\NHibernate\nhibernate\src\NHibernate\Hql\Ast\ANTLR\PolymorphicQuerySourceDetector.cs: line 27
at NHibernate.Hql.Ast.ANTLR.AstPolymorphicProcessor.Process() in d:\Source\NHibernate\nhibernate\src\NHibernate\Hql\Ast\ANTLR\AstPolymorphicProcessor.cs: line 30
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in d:\Source\NHibernate\nhibernate\src\NHibernate\Hql\Ast\ANTLR\ASTQueryTranslatorFactory.cs: line 35
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in d:\Source\NHibernate\nhibernate\src\NHibernate\Hql\Ast\ANTLR\ASTQueryTranslatorFactory.cs: line 27
at NHibernate.Engine.Query.HQLExpressionQueryPlan..ctor(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in d:\Source\NHibernate\nhibernate\src\NHibernate\Engine\Query\HQLExpressionQueryPlan.cs: line 27
at NHibernate.Engine.Query.HQLExpressionQueryPlan..ctor(String expressionStr, IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in d:\Source\NHibernate\nhibernate\src\NHibernate\Engine\Query\HQLExpressionQueryPlan.cs: line 17
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters) in d:\Source\NHibernate\nhibernate\src\NHibernate\Engine\Query\QueryPlanCache.cs: line 89
at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow) in d:\Source\NHibernate\nhibernate\src\NHibernate\Impl\AbstractSessionImpl.cs: line 302
at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression) in d:\Source\NHibernate\nhibernate\src\NHibernate\Impl\AbstractSessionImpl.cs: line 258
at NHibernate.Linq.NhQueryProvider.Execute(Expression expression) in d:\Source\NHibernate\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 24
at NHibernate.Linq.NhQueryProvider.Execute(Expression expression) in d:\Source\NHibernate\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs: line 55
at Remotion.Data.Linq.QueryableBase`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList(IEnumerable`1 source)
at Tests.LinqTests.OfType() in LinqTests.cs: line 55

LINQ query is:

(from p
in this.Session.Query<Animal>().OfType<Crocodile>()
where p.TeethCount == 1
select p).ToList();

This is clearly not a sensible thing to do but it demonstrates the bug quite nicely.

If the where clause is excluded the query runs OK.

Both queries are in attached unit test against SQLite

Environment

None

Attachments

2

Activity

Show:

Dean Ward October 18, 2010 at 2:16 PM

Same patch as NH-2381. See comments there for detail.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created October 12, 2010 at 1:48 PM
Updated March 8, 2011 at 11:28 AM
Resolved December 18, 2010 at 7:58 AM
Who's Looking?