Linq Provider doesn't recognize CompareTo method

Description

I have the following simplified data model:

public class Record
{
public DateTime TimeOfCreation { get; set; }
}

Driver class and dialect are configured as follows:
<property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
<property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>

I'm using ComponentOne Silverlight 4 grid which comunicates with server using RIA Services. When I filter records by TimeOfCreation filed, C1 grid generates Linq expression equals to this one:

session.Query<Record>().Where(x => x.TimeOfCreation.CompareTo(new DateTime(634609728000000000, DateTimeKind.Unspecified)) >= 0)

which causes following error:

Test method DataModel.Test.NHibernateDataContextTest.TestComponentOneLinqQuery threw exception:
System.NotSupportedException: Int32 CompareTo(System.DateTime)

Stack trace details:

NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitMethodCallExpression(MethodCallExpression expression) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Linq\Visitors\HqlGeneratorExpressionTreeVisitor.cs: line 419
NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitExpression(Expression expression) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Linq\Visitors\HqlGeneratorExpressionTreeVisitor.cs: line 90
NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitBinaryExpression(BinaryExpression expression)
NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitExpression(Expression expression) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Linq\Visitors\HqlGeneratorExpressionTreeVisitor.cs: line 80
NHibernate.Linq.Visitors.QueryModelVisitor.VisitWhereClause(WhereClause whereClause, QueryModel queryModel, Int32 index) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Linq\Visitors\QueryModelVisitor.cs: line 215
Remotion.Linq.Clauses.WhereClause.Accept(IQueryModelVisitor visitor, QueryModel queryModel, Int32 index)
Remotion.Linq.QueryModelVisitorBase.VisitBodyClauses(ObservableCollection`1 bodyClauses, QueryModel queryModel)
Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)
NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Linq\Visitors\QueryModelVisitor.cs: line 57
NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor sessionFactory) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Linq\NhLinqExpression.cs: line 62
NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Hql\Ast\ANTLR\ASTQueryTranslatorFactory.cs: line 27
NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Engine\Query\QueryPlanCache.cs: line 88
NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Impl\AbstractSessionImpl.cs: line 312
NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Impl\AbstractSessionImpl.cs: line 268
NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Linq\DefaultQueryProvider.cs: line 69
NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Linq\DefaultQueryProvider.cs: line 33
NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression) in c:\Users\oskar.berggren\Documents\Projects\nhibernate-core-3\src\NHibernate\Linq\DefaultQueryProvider.cs: line 40
Remotion.Linq.QueryableBase`1.GetEnumerator()
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
DataModel.Test.NHibernateDataContextTest.TestComponentOneLinqQuery()

Environment

None

Activity

Alex Zaytsev 
September 8, 2014 at 11:31 AM

Close issues resolved in 3.3.3

Alex Zaytsev 
January 8, 2013 at 12:27 AM

Fixed in 3.3.x aea113e140c45409ae44251cfeadd77a18728d0b

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created April 25, 2012 at 2:42 PM
Updated September 8, 2014 at 11:31 AM
Resolved January 8, 2013 at 12:27 AM
Who's Looking?