Hello,

I tried to post a followup that didn't seem to go through; apologies if 
both this and the previous message go through.

I created a simple project that illustrates the problem and attached it to 
this message. I tested that the various URLs "work" in the sense that they 
don't crash, though I haven't checked that the correct data comes back. I 
did watch the queries through SQL Server Profiler, and they seem right.

These URLs fail with the same exception at the same place, though the stack 
trace isn't consistent:

http://localhost:48576/OData/Three(0)/Fours?$expand=Three($expand=Two)
http://localhost:48576/OData/Three?$expand=Two($expand=One)

These succeed:

http://localhost:48576/OData/Three
http://localhost:48576/OData/Three?$expand=Two
http://localhost:48576/OData/Three(0)/Fours?
http://localhost:48576/OData/Three(0)/Fours?$expand=Three

Thanks,

Don

On Thursday, September 3, 2015 at 2:43:47 PM UTC-4, Don Lavelle wrote:
>
> Hello,
>
> I'm using NH 4.0.4.4000 to serve data through OData 
> using Microsoft.AspNet.OData 5.7.0. When I try to use $expand at multiple 
> levels, e.g., 
> http://server/WebApp/OData/Profile(2848)/MentorshipsAsMentor?$expand=Mentee($expand=InstitutionalAccount),
>  
> I keep getting an NullReferenceException in NHibernate at:
>
>    at 
> NHibernate.Linq.Visitors.ExpressionKeyVisitor.VisitConstantExpression(ConstantExpression
>  
> expression)
>    at 
> NHibernate.Linq.Visitors.ExpressionKeyVisitor.VisitBinaryExpression(BinaryExpression
>  
> expression)
>    at 
> NHibernate.Linq.Visitors.ExpressionKeyVisitor.VisitConditionalExpression(ConditionalExpression
>  
> expression)
>    at 
> NHibernate.Linq.Visitors.ExpressionKeyVisitor.VisitMemberExpression(MemberExpression
>  
> expression)
>    at 
> NHibernate.Linq.Visitors.SelectJoinDetector.VisitMemberExpression(MemberExpression
>  
> expression)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitConditionalExpression(ConditionalExpression
>  
> expression)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberAssignment(MemberAssignment
>  
> memberAssigment)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1 
> list, Func`2 visitMethod)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberInitExpression(MemberInitExpression
>  
> expression)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberAssignment(MemberAssignment
>  
> memberAssigment)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1 
> list, Func`2 visitMethod)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberInitExpression(MemberInitExpression
>  
> expression)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberAssignment(MemberAssignment
>  
> memberAssigment)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1 
> list, Func`2 visitMethod)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberInitExpression(MemberInitExpression
>  
> expression)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberAssignment(MemberAssignment
>  
> memberAssigment)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1 
> list, Func`2 visitMethod)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberInitExpression(MemberInitExpression
>  
> expression)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberAssignment(MemberAssignment
>  
> memberAssigment)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1 
> list, Func`2 visitMethod)
>    at 
> Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberInitExpression(MemberInitExpression
>  
> expression)
>    at Remotion.Linq.Clauses.SelectClause.TransformExpressions(Func`2 
> transformation)
>    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, Boolean filter)
>    at 
> NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IQueryExpression
>  
> queryExpression, String collectionRole, Boolean shallow, IDictionary`2 
> filters, ISessionFactoryImplementor factory)
>    at NHibernate.Engine.Query.QueryExpressionPlan..ctor(IQueryExpression 
> queryExpression, 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.Execute(Expression expression)
>    at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression 
> expression)
>    at Remotion.Linq.QueryableBase`1.GetEnumerator()
>    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
>    at System.Web.OData.Query.TruncatedCollection`1..ctor(IQueryable`1 
> source, Int32 pageSize)
>    at 
> System.Web.OData.Query.ODataQueryOptions.LimitResults[T](IQueryable`1 
> queryable, Int32 limit, Boolean& resultsLimited)
>
> I downloaded the NH source and built it so I can do a little debugging, 
> but nothing obvious struck me that I was doing wrong. The thing that is 
> null is _constantToParameterMap in 
> NHibernate.Linq.Visitors.ExpressionKeyVisitor in that call. If I copy the 
> entire object tree to new objects that don't come out of NH, this doesn't 
> happen.
>
> Any ideas?
>
> Thanks,
>
>     Don
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Attachment: NhODataTest.tar.gz
Description: Binary data

Reply via email to