Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I map a List which contains entities of same type as of parent type using Fluent NHibernate?
    primarykey
    data
    text
    <p>I have an entity like this </p> <pre><code>public class Person { public virtual int Pkey { get; set; } public virtual string Name { get; set; } public List&lt;Person&gt; Friends{ get; set; } } </code></pre> <p>and its table information is like this</p> <pre><code>create table Person ( PKey int not null IDENTITY, Name varchar (20), primary key (PKey) ) </code></pre> <p>To get list of Friends, I am maintaining another table like this</p> <pre><code>Create table Friends ( PKey int not null IDENTITY, PersonFKey int not null Foreign key references Person(PKey), FriendFKey int not null Foreign key references Person(PKey) ) </code></pre> <p>Now when I do mapping like as below, I am getting some error (because of mapping problem)</p> <pre><code> public class PersonMap : ClassMap&lt;Person&gt; { public PersonMap() { Id(x =&gt; x.Pkey); Map(x =&gt; x.Name); HasManyToMany(x =&gt; x.Friends).Cascade.All().Table("Friends").ParentKeyColumn("PersonFKey"); } } </code></pre> <p>Exception thrown is,</p> <pre><code>FluentConfigurationException: "An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail." </code></pre> <p>With inner exception,</p> <pre><code>InvalidProxyTypeException: The following types may not be used as proxies: FluentNhibernateLearning.Entities.Person: method get_Friends should be 'public/protected virtual' or 'protected internal virtual' FluentNhibernateLearning.Entities.Person: method set_Friends should be 'public/protected virtual' or 'protected internal virtual' </code></pre> <p>Can anyone help me pointing what I am missing?</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.
 

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