What ?You don't know the underling DB ? and how you are configuring NH ?
Dateadd is a specific function for MsSQL in others RDBMS probably you will
have something else (for example ADD_MONTHS(aDate,num_months) in Oracle).
HQL is extensible trough dialect so you can register a custom function
named: SumMonth(date, numOfMonth)
You can use SumMonth in HQL.
In your custom dialects you will translate SumMonth as:
- in YourMsSQLDialect : Dateadd(mm, numOfMonth, aDate)
- in YourOracleSQLDialect : ADD_MONTHS(aDate, numOfMonth)
- in YourPostGreDialect : aDate::date + cast('1 months' as interval)
etc.
Is the same concept used for extension methods in C#.
When you need an extension method what you do ?
Are you asking to Microsoft to include it in the next .NET version ?
2009/6/2 Dmitiry Nagirnyak <[email protected]>
> Thanks. I see.
> But how adding a new dialect can solve the issue when writing HQL we don't
> know about a DB we are using.
> Extending dialect we have to do it for each supported DB and instead of
> using default NH dialect we have to force to use customised dialects for
> each DB.
>
> 2009/6/3 Fabio Maulo <[email protected]>
>
>> Take a look
>> here<http://nhibernate.svn.sourceforge.net/viewvc/nhibernate/trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs?revision=4056&view=markup>
>> .
>>
>> As you can see the MsSql2008Dialect is only an extension
>> of MsSql2005Dialect registering some new column type and
>> registering/overriding some functions.
>> You can do the same in your project.
>> After that you can use you own dialect:
>> <property
>> name="dialect">YourCompany.NHExtensions.YourMsSqlDialect,
>> YourCompany.NHExtensions </property>
>>
>>
>> 2009/6/1 Dmitiry Nagirnyak <[email protected]>
>>
>>> You can register the corresponding function in your dialect extension
>>>> (your custom dialect inherited from standard).
>>>
>>> Don't you mind to give a little more background please (sorry I'm
>>> really new to NH)?
>>>
>>>
>>>
>>
>>
>> --
>> Fabio Maulo
>> >>
>>
--
Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---