我有一个问题可以问你,亲爱的社区,你可能已经猜到了。所以。 我希望NHibernate根据对表值sql函数的评估过滤查询结果。通过NHibernate的产生 可能的SQL查询可能类似于如下:我可以在NHibernate中使用表值函数作为查询源吗?
SELECT
[whatever]
FROM
[whatever]
INNER JOIN dbo.FnMyTableValuedFunction() as MyAlias ON
[whatever].FirstDesiredKey = MyAlias.FirstDesiredKey
AND
[whatever].SecondDesiredKey = MyAlias.SecondDesiredKey
或者也可以这样写:
SELECT
[whatever]
FROM
[whatever]
WHERE
EXISTS(
SELECT
1
FROM
dbo.FnMyTableValuedFunction() AS MyAlias
WHERE
[whatever].FirstDesiredKey = MyAlias.FirstDesiredKey
AND
[whatever].SecondDesiredKey = MyAlias.SecondDesiredKey
)
这样的查询我想用标准的API生成。 据我所知,没有办法告诉NHibernate它应该加入什么以及如何加入。所以可能存在的一个解决方案是第二个。
不幸的是,我没有足够的幸运了解如何使用表值函数作为相关子查询的查询源。你能帮助我吗?