Question

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"));
Was it helpful?

Solution

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.

OTHER TIPS

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());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top