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.

Reply via email to