How Can use a native sqlquery (session.CreateSqlQuery) as filtering subquery in another QueryOver:
// Get ids
var idsq = _session.CreateSQLQuery(
"select Id from [dbo].[SomeFunction](:parameter)")
.AddEntity(typeof(long)).
SetParameter("parameter", folderId);
// get entities by filtering where in (subquery)
MyEntity entityAlias = null;
var listOfEntities = await _session.QueryOver(() => entityAlias).
Where(x=>x.Id).IsIn(idsq).
OrderBy(x => x.Name).Asc.
ListAsync(cancelToken).ConfigureAwait(false);
idsqto the client, which is probably a bad idea as you don't know how large it is. You can probably add[dbo].[SomeFunction]to a custom sql dialect and use it that way - see nhibernate.info/blog/2009/03/13/… or ayende.com/blog/1720/using-sql-functions-in-nhibernate.WithSubquery.WhereProperty(x => x.Id).In(...)but then theInrequires aQueryOverquery.Projections.SqlFunction