Hi,
I have a question regarding how to query collections effectively. I have a class QuestionTemplate which has 2 collections, Domains and Subdomains.
The mapping looks like this:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="OzoneHR.Domain"
namespace="OzoneHR.Domain.Questionnaires">
<class name="QuestionTemplate" table="QuestionTemplate">
<id name="Id" access="nosetter.camelcase-underscore"
column="QuestionTemplateID" type="Int32">
<generator class="identity" />
</id>
<property name="QuestionText" column="QuestionText" type="String" not-null="true" access="nosetter.camelcase-underscore" />
<bag name="SubDomains"
table="QuestionTemplateInSubdomain"
cascade="all"
access="nosetter.camelcase-underscore"
>
<key column="QuestionTemplateID" />
<composite-element class="QuestionnaireSubdomain">
<property name="SubdomainName" access="nosetter.camelcase-underscore" column="Subdomain" not-null="true" />
</composite-element>
</bag>
<bag name="Domains"
table="QuestionTemplateInDomain"
cascade="all"
access="nosetter.camelcase-underscore"
>
<key column="QuestionTemplateID" />
<composite-element class="QuestionnaireDomain">
<property name="DomainName" access="nosetter.camelcase-underscore" column="Domain" not-null="true" />
</composite-element>
</bag>
</class>
</hibernate-mapping>
What I'd like to be able to do is write a query that is supplied a questiontext value and a list of strings for both Domains and Subdomains and return any QuestionTemplate that either matched the supplied QuestionText value, or had match in either of its collections for any of the values supplied in the lists.
Something like
Code:
FindTemplateMatches(string questionText, List<string> domains, List<string> subdomains)
{
// return any question template with a match on questionText, or which has any of the domains or subdomains supplied.
}
Thanks,
Matt[/code]