Hi,

You can register extensions methods, and their ICriterion replacements.
 For example, there is a MonthPart() extension to a DateTime:

https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs#L705

You create an extension method, and a corresponding implementation that
returns an ICriterion (in much the same way as the Linq extensions return
an HQL tree):

https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Criterion/ProjectionsExtensions.cs#L57-L66

You can then register this implementation in the QueryOver
ExpressionProcessor:

https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Impl/ExpressionProcessor.cs#L162

However, I think you'll still need two implementations (i.e., one to form
the expression using SQL/ICriteria, and one in in plain old C# code - I'm
not sure I can see a way round that for QueryOver.

Does that help?

Cheers,
    Richard




On 1 May 2013 22:33, <[email protected]> wrote:

> I'm trying to use calculated properties that I use with Query<T>() inside
> of a QueryOver<T>(). When using a LINQ query, I can register custom
> generators with a customDefaultLinqToHqlGeneratorsRegistry. This works
> great for calculated properties from an 
> expression<http://hendryluk.wordpress.com/2011/09/06/nhibernate-linq-ing-calculated-properties/>
>  so
> the code isn't duplicated.
>
> I can't seem to find the extension point for registering custom generators
> for the QueryOver API. Does it exist?
>
> I'd really like to *not* have to duplicate the calculated property logic
> inside of a raw SQL string (Map(x =>
> x.Prop).Formula("query").LazyLoad().Access.ReadOnly()). This means twice
> the logic and twice the number of tests.
>
> --
> 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?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to