使用 2 个表连接和 wheres 进行删除

发布于 2024-08-07 18:57:54 字数 410 浏览 9 评论 0原文

我有 2 个表,

POST (idpost, user, text)
COMMENT (idcomment, idpost, text)

我想删除帖子中包含“usertest”这样的用户的所有评论,

delete from COMMENT c join POST p on c.idpost = p.idpost
where p.user like 'usertest'

我该如何在 subsonic 3 中执行此操作?

我尝试过类似的方法,但是,当然,它不起作用,

COMMENT.Delete(x => x.POST.where(y => y.user == "usertest"));

I have 2 tables,

POST (idpost, user, text)
COMMENT (idcomment, idpost, text)

I want to delete all comments with post that have a user like "usertest",

delete from COMMENT c join POST p on c.idpost = p.idpost
where p.user like 'usertest'

How do I do this in subsonic 3?

I tried something like this, but, off course, it doesn't work,

COMMENT.Delete(x => x.POST.where(y => y.user == "usertest"));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无所谓啦 2024-08-14 18:57:54

您应该能够执行以下操作:

IQueryable<Person> query = from comments in Comment.All()
                           join posts in Post.All()
                             on posts.idpost equals comment.idpost
                           select comments;

Comment.GetRepo().Delete(query.ToList());

You should be able to do the following:

IQueryable<Person> query = from comments in Comment.All()
                           join posts in Post.All()
                             on posts.idpost equals comment.idpost
                           select comments;

Comment.GetRepo().Delete(query.ToList());
紫瑟鸿黎 2024-08-14 18:57:54

我不是亚音速程序员,但 StackOverflow 中有另一篇关于删除表中所有记录的文章:

如何使用 SubSonic 3 删除表中的所有记录

这似乎是一个很好的起点,但这只是一个猜测。

I'm not a subsonic programmer, but there is another article in StackOverflow about deleting all records in a table:

How to delete all records in a table using SubSonic 3

It seemed like this might be a good starting place, but that's just a guess.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文