Custom SQL function for NHibernate dialect

后端 未结 2 1546
半阙折子戏
半阙折子戏 2020-12-20 22:39

I want to be able to call a custom function called \"recent_date\" as part of my HQL. Like this: [Date] >= recent_date()

I created a new dialect, inh

相关标签:
2条回答
  • 2020-12-20 23:13

    I thought you had to prefix your function with "dbo." whenever you used it. My custom dialect has this:

    RegisterFunction("dbo.isbounded", new SQLFunctionTemplate(NHibernateUtil.Double, "dbo.IsBounded(?1, ?2, ?3, ?4, ?5, ?6)"));
    

    It's then called using

    Expression.Sql("dbo.IsBounded(...)")
    
    0 讨论(0)
  • 2020-12-20 23:15

    I think, Where is a SQL statement, not a HQL statement. So it doesn't know the function. It only works for HQL, in queries or filters.

    0 讨论(0)
提交回复
热议问题