Reputation: 812
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"));
Upvotes: 1
Views: 441
Reputation: 8687
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());
Upvotes: 1
Reputation: 8395
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.
Upvotes: 0