I mentioned that I am using the NHibernate got from NuGet. The assembly version is 3.3.1.4000
Can you please let me know where to test a newer build? Thanks. On Sunday, January 6, 2013 12:08:06 AM UTC+2, Oskar Berggren wrote: > > Sounds like it's covered by one of the WCF-DS related issues fixed for > the upcoming 3.3.3 release (e.g. NH-3261, but others relate to this > also). > > It would be useful if you could try a build from the 3.3.x branch to > see if the issue is resolved for you. > > /Oskar > > > 2013/1/5 Andrewz <[email protected] <javascript:>>: > > Any ideas or hints on this issue would be great, > > > > Thanks > > > > > > On Saturday, January 5, 2013 9:08:17 PM UTC+2, Andrewz wrote: > >> > >> I created a web app in Visual Studio 2010, added NHibernate and > >> FluentNHibernate by NuGet. > >> My intention is to test how oData works with latest NHibernate and SQL > >> Server 2008 R2 > >> It's a simple app with one table, User. > >> I added like 5,000 users in the User table to have data to query. > >> > >> I am doing the following queries which worked OK: > >> > >> > http://localhost:4380/UserService.svc/Users()?$top=10&$inlinecount=allpages > >> > >> > http://localhost:4380/UserService.svc/Users()?$filter=FirstName%20eq%20'Andrew0'&$top=10&$inlinecount=allpages > > >> > >> My question is why the following query fails: > >> > >> > http://localhost:4380/UserService.svc/Users()?$filter=substringof('Andrew',tolower(FirstName))&$orderby=LastName&$top=10&$inlinecount=allpages > > > >> > >> The exception is the following(see below the stack trace): > >> Unable to cast object of type 'NHibernate.Hql.Ast.HqlCast' to type > >> 'NHibernate.Hql.Ast.HqlBooleanExpression'. > >> > >> Here are my classes: > >> > >> [DataServiceKey("Id")] > >> [DataServiceEntity] > >> public class User > >> { > >> public virtual int Id { get; protected set; } > >> public virtual string FirstName { get; set; } > >> public virtual string LastName { get; set; } > >> } > >> > >> public class UserMapping : ClassMap<User> > >> { > >> public UserMapping() > >> { > >> Id(user => user.Id).GeneratedBy.Identity(); > >> Map(user => user.FirstName).Not.Nullable().Length(50); > >> Map(user => user.LastName).Not.Nullable().Length(50); > >> } > >> } > >> > >> public class UserDataContext > >> { > >> public ISession Session { set; get; } > >> > >> public IQueryable<User> Users > >> { > >> get > >> { > >> return this.Session.Query<User>(); > >> } > >> } > >> } > >> > >> [ServiceBehavior(IncludeExceptionDetailInFaults = true)] > >> public class UserService : DataService<UserDataContext>, > IDisposable > >> { > >> ISession session; > >> > >> public static void InitializeService(DataServiceConfiguration > >> config) > >> { > >> config.SetEntitySetAccessRule("*", EntitySetRights.All); > >> config.DataServiceBehavior.MaxProtocolVersion = > >> DataServiceProtocolVersion.V2; > >> config.UseVerboseErrors = true; > >> } > >> > >> protected override UserDataContext CreateDataSource() > >> { > >> var sessionFactory = new HibernateSessionFactory(); > >> this.session = sessionFactory.OpenSession(); > >> return new UserDataContext() > >> { > >> Session = this.session > >> }; > >> } > >> > >> public void Dispose() > >> { > >> this.session.Dispose(); > >> this.session = null; > >> } > >> } > >> > >> > >> Here is the web response I see in Fiddler: > >> > >> <?xml version="1.0" encoding="utf-8" standalone="yes"?> > >> <error > >> xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> > > >> <code></code> > >> <message xml:lang="en-US">An error occurred while processing this > >> request.</message> > >> <innererror> > >> <message>Exception has been thrown by the target of an > >> invocation.</message> > >> <type>System.Reflection.TargetInvocationException</type> > >> <stacktrace> at > >> System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, > >> Object target, Object[] arguments, SignatureStruct& sig, > >> MethodAttributes methodAttributes, RuntimeType typeOwner)
 > >> at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo > >> method, Object target, Object[] arguments, Signature sig, > MethodAttributes > >> methodAttributes, RuntimeType typeOwner)
 > >> at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, > BindingFlags > >> invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, > Boolean > >> skipVisibilityChecks)
 > >> at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, > BindingFlags > >> invokeAttr, Binder binder, Object[] parameters, CultureInfo > culture)
 > >> at System.Reflection.MethodBase.Invoke(Object obj, Object[] > >> parameters)
 > >> at System.Data.Services.RequestQueryProcessor.ProcessCount()
 > >> at System.Data.Services.RequestQueryProcessor.ProcessQuery()
 > >> at > System.Data.Services.RequestQueryProcessor.ProcessQuery(IDataService > >> service, RequestDescription description)
 > >> at System.Data.Services.RequestUriProcessor.ProcessRequestUri(Uri > >> absoluteRequestUri, IDataService service)
 > >> at > System.Data.Services.DataService`1.ProcessIncomingRequestUri()
 > >> at System.Data.Services.DataService`1.HandleRequest()</stacktrace> > >> <internalexception> > >> <message>Unable to cast object of type > 'NHibernate.Hql.Ast.HqlCast' > >> to type 'NHibernate.Hql.Ast.HqlBooleanExpression'.</message> > >> <type>System.InvalidCastException</type> > >> <stacktrace> at > >> > NHibernate.Hql.Ast.HqlTreeNodeExtensions.AsBooleanExpression(HqlTreeNode > >> node)
 > >> at > >> NHibernate.Linq.Visitors.QueryModelVisitor.VisitWhereClause(WhereClause > >> whereClause, QueryModel queryModel, Int32 index)
 > >> at Remotion.Linq.Clauses.WhereClause.Accept(IQueryModelVisitor > visitor, > >> 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.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.PrepareQuery(Expression > >> expression, IQuery& query, NhLinqExpression& nhQuery)
 > >> at NHibernate.Linq.DefaultQueryProvider.Execute(Expression > >> expression)
 > >> at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression > >> expression)
 > >> at System.Linq.Queryable.LongCount[TSource](IQueryable`1 > source)
 > >> at > >> > System.Data.Services.RequestQueryProcessor.CountQueryResult[TElement](IQueryable`1 > > > >> query)</stacktrace> > >> </internalexception> > >> </innererror> > >> </error> > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "nhusers" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/nhusers/-/_B79zDbcu1MJ. > > > > To post to this group, send email to [email protected]<javascript:>. > > > To unsubscribe from this group, send email to > > [email protected] <javascript:>. > > For more options, visit this group at > > http://groups.google.com/group/nhusers?hl=en. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/Gpp7lCadQf0J. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
