开发者

Delete using 2 tables join and wheres

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",

开发者_如何学JAVA
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"));


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());


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜