Given the following mapping file...
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Infosnap.Serenity.Domain.RosterEntry, Infosnap.Serenity.Domain" table="RosterEntries" lazy="false">
<id name="ID" column="ID" type="Int32" unsaved-value="0">
<generator class="identity" />
</id>
<property name="ActionID" column="ActionID" type="Int32" />
<property name="ExternalStudentID" column="ExternalStudentID" type="String" length="25" />
<property name="StudentFirstName" column="StudentFirstName" type="String" length="25" />
<property name="StudentLastName" column="StudentLastName" type="String" length="25" />
<property name="ExternalFamilyID" column="ExternalFamilyID" type="String" length="25" />
<property name="FamilyEmailAddress" column="FamilyEmailAddress" type="String" length="100" />
<property name="Tags" column="Tags" type="String" length="100" />
<many-to-one name="Invitation" class="Infosnap.Serenity.Domain.Invitation, Infosnap.Serenity.Domain"
column="InvitationID" cascade="all" unique="true" />
<map name="DataValues" table="RosterData" access="nosetter.camelcase-underscore" lazy="true">
<key column="RosterEntryID"/>
<index column="FieldName" type="String" length="50" />
<element column="FieldValue" type="String" length="4000" />
</map>
</class>
</hibernate-mapping>
I want to construct a query similar to the following SQL...
Code:
select a.*
from RosterEntries a
join RosterData b on a.ID = b.RosterEntryID
where b.FieldName = 'MyFieldName'
and b.FieldValue = 'SomeFieldValue'
Therefore, if "MyFieldName" does not exist, or if it does and the associated FieldValue does not equal "SomeFieldValue", then I do not want the record returned.
Conceptually, I want to do something like this...
Code:
from RosterEntry entry
where entry.DataValues['MyFieldName'] = 'SomeFieldValue'
But, I am not sure if this approach is even supported.
I have seen some examples where you can do this IF the map is a map of entities, but I have a simple map of strings. Basically, the DataValues map is a string dictionary in .Net.
Does anyone know how to do this? Thanks in advance!
Kevin