The issue lies in HqlIdent constructor. It uses System.TypeCode, but unfortunately, there's no definition TypeCode.DateTimeOffset. I think a possible fix is by checking System.Type directly like Guid (type == typeof(Guid)), instead of checking using TypeCode.
Stack trace:
System.NotSupportedException : Don't currently support idents of type DateTimeOffset at NHibernate.Hql.Ast.HqlIdent..ctor(IASTFactory factory, Type type) at NHibernate.Hql.Ast.HqlCast..ctor(IASTFactory factory, HqlExpression expression, Type type) at NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitNhMin(NhMinExpression expression) at NHibernate.Linq.Visitors.SelectClauseVisitor.VisitExpression(Expression expression) at NHibernate.Linq.Visitors.SelectClauseVisitor.Visit(Expression expression) at NHibernate.Linq.Visitors.QueryModelVisitor.VisitSelectClause(SelectClause selectClause, QueryModel queryModel) at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel) at NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root) at NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitSubQueryExpression(SubQueryExpression expression) at NHibernate.Linq.Visitors.QueryModelVisitor.VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, Int32 index) at Remotion.Linq.QueryModelVisitorBase.VisitBodyClauses(ObservableCollection`1 bodyClauses, QueryModel queryModel) at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel) at NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root) at NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor sessionFactory) at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) at NHibernate.Engine.Query.HQLExpressionQueryPlan.CreateTranslators(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters) at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow) at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression) at NHibernate.Linq.DefaultQueryProvider.ExecuteFuture(Expression expression) at NHibernate.Linq.LinqExtensionMethods.ToFuture(IQueryable`1 query)
Actually, I'm asking first whether it'd be right thing to do, as I really have no clear idea what it's about. But I'll try to create a fix, to see if it would work, as I find time this weekend. Any ETA for 3.3.3?
I'm still not sure which part of this query causing it (is it the OrderBy or the projection), but here's the failing query:
session.Query<Transaction>()
.OrderBy(transaction => transaction.Postings.Min(y => y.Date));
The issue lies in HqlIdent constructor.
It uses System.TypeCode, but unfortunately, there's no definition TypeCode.DateTimeOffset.
I think a possible fix is by checking System.Type directly like Guid (type == typeof(Guid)), instead of checking using TypeCode.
Stack trace:
System.NotSupportedException : Don't currently support idents of type DateTimeOffset
at NHibernate.Hql.Ast.HqlIdent..ctor(IASTFactory factory, Type type)
at NHibernate.Hql.Ast.HqlCast..ctor(IASTFactory factory, HqlExpression expression, Type type)
at NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitNhMin(NhMinExpression expression)
at NHibernate.Linq.Visitors.SelectClauseVisitor.VisitExpression(Expression expression)
at NHibernate.Linq.Visitors.SelectClauseVisitor.Visit(Expression expression)
at NHibernate.Linq.Visitors.QueryModelVisitor.VisitSelectClause(SelectClause selectClause, QueryModel queryModel)
at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)
at NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root)
at NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitSubQueryExpression(SubQueryExpression expression)
at NHibernate.Linq.Visitors.QueryModelVisitor.VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, Int32 index)
at Remotion.Linq.QueryModelVisitorBase.VisitBodyClauses(ObservableCollection`1 bodyClauses, QueryModel queryModel)
at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)
at NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root)
at NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor sessionFactory)
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.HQLExpressionQueryPlan.CreateTranslators(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters)
at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)
at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression)
at NHibernate.Linq.DefaultQueryProvider.ExecuteFuture(Expression expression)
at NHibernate.Linq.LinqExtensionMethods.ToFuture(IQueryable`1 query)