gpt4 book ai didi

nhibernate - id不在列表中的查询

转载 作者:行者123 更新时间:2023-12-04 00:22:32 24 4
gpt4 key购买 nike

我已经为此苦苦挣扎了一段时间,所以我希望你们中的一些 QueryOver 专家可以提供帮助。

我有一个博客文章列表。您可以对每篇博客文章进行投票,我希望(除其他外)收到用户未投票的文章列表。

首先,我正在考虑做类似的事情:

Session.QueryOver<BlogPost>()
.WhereRestrictionOn(bp => bp.Id)
.NotIn(existingBlogPostVotes);

(existingBlogPostVoteIds 是已投票博文的 ID)

但这在 QueryOver 框架中不存在。

我发现我可以像这样在 Criteria 中做到这一点:
var crit =
Session.CreateCriteria<BlogPost>()
.Add(Restrictions.Not(Restrictions.In("Id",existingBlogPostVotes)));

但我会在 QueryOver 而不是 Criteria 中做到这一点。

这将如何在 QueryOver 中完成?

最佳答案

怎么样Not.IsIn() :

   Session.QueryOver<BlogPost>()
.WhereRestrictionOn(bp => bp.Id)
.Not.IsIn(existingBlogPostVotes);

或者,这也可以在 Linq 提供程序中完成:
   Session.Query<BlogPost>()
.Where(bp => !existingBlogPostVotes.Contains(bp.Id));

关于nhibernate - id不在列表中的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9444447/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com