Re: [nhusers] StandardSQLFunction in 4.0.4

2016-04-06 Thread projectmercy
Thank you for your help, It works with that way.

I would like to try to see if I can get it to work the way it used to work. 
I pulled the unit test project to do some experimentation. Do you think 
that it would be worth submitting a ticket about it if I come up with a fix?

-- 
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 nhusers+unsubscr...@googlegroups.com.
To post to this group, send email to nhusers@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.


Re: [nhusers] StandardSQLFunction in 4.0.4

2016-04-04 Thread Gunnar Liljas
Yup, it's the array which causes it. I suggest you change

public static DateTime GreatestDateTime(DateTime?[] expression)

to

public static DateTime? GreatestDateTime(DateTime? expression1, DateTime?
expression2)

and extra overloads, with more arguments, if you need them. Note that the
return type should really be nullable, since all arguments are.

/G

2016-04-04 17:56 GMT+02:00 projectmercy :

> I posted this on StackOverflow, but I haven't been able to get any
> traction on it, so I'll try asking here. I'm trying to port from 3.3.4 to
> 4.0.4. For the most part it's been pretty seamless, but I've run into an
> issue with my SQLite dialect that I use for my tests. Our production code
> uses Oracle, and so we've setup an alias from Oracle's *greatest*
> function to SQLite's *max* function. This worked fine in 3.3.4, but
> doesn't appear to work currently in 4.0.4 with my code.
>
> So in our SQLite dialect constructor we have:
>
> RegisterFunction(GreatestFunctionExtension.GreatestFunction, new
> StandardSQLFunction("max", NHibernateUtil.DateTime));
>
>
> The extension is defined as:
>
> public static class GreatestFunctionExtension
> {
> public const String GreatestFunction = "greatest";
> [LinqExtensionMethod(GreatestFunction)]
> public static DateTime GreatestDateTime(DateTime?[] expression)
> {
> throw new NotImplementedException("GreatestDateTime");
> }
> }
>
>
> So we use this down in the projection for the query which looks similar too
>
> Session.Query().Select(f => new
> {
> GreatestDate =
> GreatestFunctionExtension.GreatestDateTime(new[]
> {
> f.Date1,
> f.Date2
> })
> }).ToList();
>
> This only results in the GreatestDateTime NotImplementedException in 4.x.
> It generates SQL like:
>
> select twodateentity0_.DATE1 as col_0_0_, twodateentity0_.DATE2 as
> col_1_0_ from TWO_DATES twodateentity0_
>
> Then it takes those two values and seems to pass them into the extension
> method.
>
> In 3.3.4 it instead looks like:
>
> select max(twodateentity0_.DATE1, twodateentity0_.DATE2) as col_0_0_
> from TWO_DATES twodateentity0_
>
> I believe it has something to do with the collection. If I change it from
> max to count, and switch the parameters to a single value, it seems to
> function correctly. I've also tried switching from an Array to a List, but
> it ends in the same result.
>
> Thank you for any help you can provide,
>
> PM
>
>
> --
> 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 nhusers+unsubscr...@googlegroups.com.
> To post to this group, send email to nhusers@googlegroups.com.
> Visit this group at https://groups.google.com/group/nhusers.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 nhusers+unsubscr...@googlegroups.com.
To post to this group, send email to nhusers@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.