I'm trying to understand if Projections can be supported through NHibernate's Linq provider. I'm using the technique described here [1] to expose my NHibernate domain via OData (WCF Data Services). It works great, but it appears projections are not supported. Is there a work around for this? Any plans to add support?
When I issue a query using the $select expression, like this: http://localhost/MyApp/MyService.svc/Customers()?$filter=CorporationId eq 1000&$select=Id,CorporationId I receive the below exception. If someone could confirm this behavior and give any guidance, it would be very much appreciated. My team and I do not know how to proceed with our current approach. -<error xmlns="' rel="nofollow" target="_new" mce_href='http:// schemas.microsoft.com/ado/2007/08/dataservices/ metadata">'>schemas.microsoft.com/.../metadata"> <code/> <message xml:lang="en-US">Not Implemented</message> -<innererror> <message>([100001] As CustomerPaymentSummary)</message> <type>System.NotSupportedException</type> <stacktrace> at NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitUnaryExpression(UnaryExpression expression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors \HqlGeneratorExpressionTreeVisitor.cs:line 337 at NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitMemberExpression(MemberExpression expression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors \HqlGeneratorExpressionTreeVisitor.cs:line 357 at NHibernate.Linq.Visitors.SelectClauseVisitor.VisitExpression(Expression expression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors \SelectClauseVisitor.cs:line 64 at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMemberAssignment(MemberAssignment memberAssigment) in :line 0 at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMemberBinding(MemberBinding memberBinding) in :line 0 at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitList[T] (ReadOnlyCollection`1 list, Func`2 visitMethod) in :line 0 at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMemberBindingList(ReadOnlyCollection`1 expressions) in :line 0 at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMemberInitExpression(MemberInitExpression expression) in :line 0 at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression) in :line 0 at NHibernate.Linq.Visitors.SelectClauseVisitor.VisitExpression(Expression expression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors \SelectClauseVisitor.cs:line 71 at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitConditionalExpression(ConditionalExpression expression) in :line 0 at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression) in :line 0 at NHibernate.Linq.Visitors.SelectClauseVisitor.VisitExpression(Expression expression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors \SelectClauseVisitor.cs:line 71 at NHibernate.Linq.Visitors.SelectClauseVisitor.Visit(Expression expression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\Visitors \SelectClauseVisitor.cs:line 41 at NHibernate.Linq.Visitors.QueryModelVisitor.VisitSelectClause(SelectClause selectClause, QueryModel queryModel) in d:\CSharp\NH\NH\nhibernate\src \NHibernate\Linq\Visitors\QueryModelVisitor.cs:line 161 at Remotion.Data.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel) in :line 0 at NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root) in d:\CSharp\NH \NH\nhibernate\src\NHibernate\Linq\Visitors\QueryModelVisitor.cs:line 61 at NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor sessionFactory) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq \NhLinqExpression.cs:line 78 at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in d:\CSharp\NH\NH\nhibernate\src \NHibernate\Hql\Ast\ANTLR\ASTQueryTranslatorFactory.cs:line 27 at NHibernate.Engine.Query.HQLExpressionQueryPlan.CreateTranslators(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in d:\CSharp\NH\NH\nhibernate\src \NHibernate\Engine\Query\HQLExpressionQueryPlan.cs:line 34 at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters) in d: \CSharp\NH\NH\nhibernate\src\NHibernate\Engine\Query \QueryPlanCache.cs:line 89 at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow) in d:\CSharp\NH\NH\nhibernate\src \NHibernate\Impl\AbstractSessionImpl.cs:line 312 at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl \AbstractSessionImpl.cs:line 268 at NHibernate.Linq.NhQueryProvider.Execute(Expression expression) in d: \CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs:line 26 at Remotion.Data.Linq.QueryableBase`1.System.Collections.IEnumerable.GetEnumerator() in :line 0 at System.Data.Services.Internal.ProjectedWrapper.EnumerableWrapper.GetEnumerator() at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)</stacktrace> </innererror> </error> [1] http://weblogs.asp.net/cibrax/archive/2010/08/13/nhibernating-a-wcf-data-service.aspx?CommentPosted=true#commentmessage -- You received this message because you are subscribed to the Google Groups "nhusers" group. 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.
