I need a little help on this. I'm trying to use a table-valued function in a select, but I got the error that this is not mapped.
dbo.FnListEvnt is not mapped [from dbo.FnListEvnt(:dt, :id, :code) ]
Function
CREATE FUNCTION [dbo].[FnListEvnt]
(@DT DATETIME, @ID INT, @CODE VARCHAR (4))
RETURNS
@RESULTADO TABLE (
ID INT ,
DT_INIC DATETIME ,
DT_TMNO DATETIME ,
CD_EVNT VARCHAR (5) )
AS
BEGIN
Custom Dialect (this is defined in .config )
public class CustomFunctionsMsSql2008Dialect : MsSql2008Dialect
{
public CustomFunctionsMsSql2008Dialect()
{
RegisterFunction("dbo.FnListEvnt", new StandardSQLFunction("dbo.FnListEvnt", null));
}
}
Query
var query = Session.CreateQuery("from dbo.FnListEvnt(:dt, :id, :code) ")
.SetDateTime("dt", dt)
.SetInt32("id", id)
.SetString("code", code);
RegisterFunctionis only useful for scalar valued functions. You may have to use a named query--is that acceptable?