Hi
I meet an issue that I cannot fix. Using a one-to-many relationship, I get the correct number of results but their value is always the one of the first element.
Here are my two tables:
I try to get all the directoryId values associated to a FormID. In my example, 1 and 70041.
Here are my domain files:
Code:
public class FormsDirectory : DomainObject<int>
{
public FormsDirectory()
: base()
{
}
public virtual int FormId
{
get;
set;
}
(...)
public override int GetHashCode()
{
return this.DirectoryId.GetHashCode();
}
}
and
Code:
public class Form : DomainObject<int>
{
private string name;
private string formNameKey;
(...)
public virtual IList<FormsDirectory> FormsDirectory
{
get { return this.formsDirectory; }
set { this.formsDirectory = value; }
}
public override int GetHashCode()
{
return this.Name.GetHashCode();
}
}
And Here are my mapping files:
Code:
<class name="Form" table="ModuleForms" lazy="true" where="FormFields is not null and FormId not in ( select e.FormId from tblEvents e) ">
<id name="Id" type="System.Int32" column="FormId">
<generator class="identity" />
</id>
(...)
<one-to-one name="SubmittedForm" class="SubmittedForm" foreign-key="FormId"/>
<bag name="FormsDirectory" table="lnkFormsDirectory" inverse="true" lazy="true">
<key column="FormID" />
<one-to-many class="FormsDirectory"/>
</bag>
</class>
AND
Code:
<class name="FormsDirectory" table="lnkFormsDirectory" mutable="false">
<id name="Id" type="System.Int32" column="FormID">
<generator class="increment"/>
</id>
(...)
</class>
In IList<FormsDirectory> recipients = this.CurrentForm.Form.FormsDirectory, I get two results (for for each entry, that's okay), but the FormsDirectory[X].DirectoryId value is always equals to 1, the value of the first entry.
I really need your help folks,
Thank you