亲爱的社区,我有一个问题要问你,你可能已经猜到了。所以。我希望 NHibernate 根据对表值 sql 函数的评估来过滤查询结果。NHibernate 生成的可能的 SQL 查询可能类似于以下内容:
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
)
我想使用 Criteria API 生成这样的查询。据我所知,没有办法告诉 NHibernate 它应该加入什么以及如何加入。因此,可能存在的一种解决方案是第二种解决方案。
不幸的是,我没有幸运地发现如何使用表值函数作为相关子查询的查询源。你能帮我做那个吗?