Note that there are some explanatory texts on larger screens.

plurals
  1. PONullReferenceException mapping collection of enum with Fluent NHibernate automapping
    primarykey
    data
    text
    <p>I have a class that contains a collection of enumeration as follows.</p> <pre><code>public enum TransactionType { ... } public class PaymentMethod { ... public virtual IList&lt;TransactionType&gt; SupportedTransactionTypes { get; set; } } </code></pre> <p>Other references to the TransactionType enumeration are working correctly but with this collection I get an exception: "NHibernate.MappingException : Association references unmapped class: mynamespace.TransactionType".</p> <p>Looking around it seems like I needed to specify the type of element mapping, i.e. one-to-many, element, or composite-element.</p> <p>I have setup the following override mappings for the PaymentMethod class:</p> <pre><code>mapping.HasMany(x =&gt; x.TransactionTypes) .Element("TransactionTypeId"), x =&gt; x.Type&lt;TransactionType&gt;()); </code></pre> <p>But this causes the following exception...</p> <p>Validation failed: System.NullReferenceException: Object reference not set to an instance of an object. at FluentNHibernate.Conventions.Inspections.OneToManyInspector.get_Class() in e:\horn.horn\orm\fluentnhibernate\Working\src\FluentNHibernate\Conventions\Inspections\OneToManyInspector.cs:line 40 at FluentNHibernate.Conventions.ProxyConvention.Apply(ICollectionInstance instance) in e:\horn.horn\orm\fluentnhibernate\Working\src\FluentNHibernate\Conventions\ProxyConvention.cs:line 79 at FluentNHibernate.Visitors.ConventionVisitor.Apply[TInspector,TInstance](IEnumerable conventions, TInstance instance) in e:\horn.horn\orm\fluentnhibernate\Working\src\FluentNHibernate\Visitors\ConventionVisitor.cs:line 269 at ...</p> <p>I have tried a lot of different variations on the mapping, including TableName, KeyColumn and anything else I can think of but I can't get this mapping to work.</p> <p>Any help appreciated...</p>
    singulars
    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.
    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