I have a list of objects called
Keywords, each with an Id.
In my database, I have a table of
Forms and a table of
KeywordReference has a
FormId and a
What I need to do is create a query that gets all
Forms where there exists a
KeywordReference between that form's
Id and all
Keywords in the original list.
So basically I have some
Form: Name: Test1 Id: 1 Form: Name: Test2 Id: 2
KeywordReference: FormId: 1 KeywordId: 1 KeywordReference: FormId: 1 KeywordId: 2 KeywordReference: FormId: 2 KeywordId: 2
And then I have a list of
Keyword: Name: Primary Id: 1 Keyword: Name: Secondary Id: 2
The query should return
Test1, because there exists a
Test1 for all
Keyword items in the list.
It should not return
Test2 because that form only matches one of the items in
How can I write such a query?
EDIT This is an example of a query that gets all forms where any match occurs between the keywords in the list and a given form, but I need to write a query where all matches occur:
var forms = from form in db.Forms join reference in db.KeywordReferences on form.Id equals reference.FormId join filter in filters on reference.DepartmentKeywordId equals filter.Id reference in the filter select form;