[VisitMethodCallExpression] calling model methods from hql

34 views
Skip to first unread message

Michael Powell

unread,
Mar 6, 2016, 3:46:34 PM3/6/16
to fluent-n...@googlegroups.com
Hello,

I've got a semi-rich domain model that supports some methods. However,
when I try to access them from within a Query<T>, I am getting
exceptions like
NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitMethodCallExpression.

If memory serves, how does one register a domain model's methods with
the linq provider? I'd like to do so automatically, if possible. Is
that upon mapping, or when?

If I need to add them as extension methods, so be it; what I want to
avoid is massive duplication of effort in my
service/manager/controller layers for stuff that should be closer, and
therefore feel more natural, to the model.

Thank you...

Regards,

Michael Powell

Gleb Chermennov

unread,
Mar 7, 2016, 4:53:16 AM3/7/16
to Fluent NHibernate
So I think you're getting NotSupportedException because NHibernate can't translate your method call to sql/hql.
Here's what you can try: http://stackoverflow.com/questions/11079852/nhibernate-overcoming-notsupportedexception

воскресенье, 6 марта 2016 г., 23:46:34 UTC+3 пользователь mwpowellhtx написал:

mwpowellhtx

unread,
Mar 8, 2016, 11:03:14 AM3/8/16
to Fluent NHibernate


On Monday, March 7, 2016 at 4:53:16 AM UTC-5, Gleb Chermennov wrote:
So I think you're getting NotSupportedException because NHibernate can't translate your method call to sql/hql.

Thank you, it's a start. I think it's more along the lines of Linq to Hql provider extensibility, but how best to connect this with Fluent and/or NHibernate?

Instinctively, I would think during a mapping, but I could be wrong; or during a follow on configuration event handler.


Thoughts?

mwpowellhtx

unread,
Mar 8, 2016, 11:05:03 AM3/8/16
to Fluent NHibernate


On Tuesday, March 8, 2016 at 11:03:14 AM UTC-5, mwpowellhtx wrote:

On Monday, March 7, 2016 at 4:53:16 AM UTC-5, Gleb Chermennov wrote:
So I think you're getting NotSupportedException because NHibernate can't translate your method call to sql/hql.

Thank you, it's a start. I think it's more along the lines of Linq to Hql provider extensibility, but how best to connect this with Fluent and/or NHibernate?

Instinctively, I would think during a mapping, but I could be wrong; or during a follow on configuration event handler.


Interestingly, I can project using ToArray or ToList extension methods, but it is inefficient to pull a whole record set in through Hql only to turn around and filter some instances afterwards. If I can work through the Linq provider as the Hql is being generated, that would be best, I think.
Reply all
Reply to author
Forward
0 new messages