Note that there are some explanatory texts on larger screens.

plurals
  1. POFluent NHibernate HasMany in Component
    primarykey
    data
    text
    <p>Below is a class model and an Oracle schema that I would like to map it to using Fluent NHibernate.</p> <pre><code>public enum EnumA { Type1, Type2, Type3 }; public class ClassB { public virtual string Property1 { get; set; } public virtual string Property2 { get; set; } } public class ClassA { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual IDictionary&lt;EnumA, IList&lt;ClassB&gt;&gt; MyDictionary { get; set; } } </code></pre> <p>TableA (NUMBER(38) ID PK, VARCHAR2(255) Name)<br> TableB (NUMBER(38) ID PK FK, NUMBER(38) Type PK, VARCHAR(255) Prop1, VARCHAR(255) Prop2)</p> <p>How should I define the Fluent NHibernate mapping class?<br> I don't mind introducing a new domain class if necessary. I have tried the following:</p> <pre><code>public class ClassB { public virtual string Property1 { get; set; } public virtual string Property2 { get; set; } } public class classC { public virtual EnumA EnumA { get; set; } IList&lt;ClassB&gt; ClassBList { get; set; } } public class ClassA { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual IDictionary&lt;EnumA, classC&gt; MyDictionary { get; set; } } </code></pre> <p>with the following mapping class</p> <pre><code> public ClassAMap() { WithTable("ClassA"); Id(x =&gt; x.ID); Map(x =&gt; x.Name); HasMany(x =&gt; x.MyDictionary).AsMap&lt;EnumA&gt;(d =&gt; d.EnumA).Component(c =&gt; { c.HasMany(e =&gt; e.ClassBList).Component(f =&gt; { f.Map(x =&gt; x.Property1); f.Map(x =&gt; x.Property1); }); }); } </code></pre> <p>However, this does not generate a valid configuration. Can anybody help?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload