var query = Expression.Sql(SqlString.Parse("EXISTS (SELECT 1 FROM dbo.MyFunction(?, ?) MF WHERE
MF.ID = {alias}.[ID])"), new object[] { param1, param2 }, new[] { NHibernateUtil.Int32, NHibernateUtil.Int32 });
var res = Session.QueryOver<Nodo>()
.Where(query)
.Where(.. other conditions ...)
.List();
Clearly the number and the type of the parameters can be changed. The table function must return a list of IDs. This doesn't work if the table function has to add extra data (so, for exampe, if the TVF calculated a rolling total and returned it then you can't use this method). You can use this method only if you use the TVF as a "selector" for which rows to return. I could have done the query using the IN clause (something like {alias}.[ID] IN (SELECT ID FROM dbo.MyFunction(?, ?)), but that doesn't work if you have a composite key, while the EXISTS variant does (in the end what I have done can be put only in the WHERE clause, and not in a JOIN)