TL version of the DR: . The code below gives me an exception to the class of associations without breaking into classes when creating a SessionFactory. What needs to be changed in the code to fix it?
Although Ayende @Rahien does not recommend using class mappings in this 2007 article, I was still in that. I used the approach he mentioned. First a bit that works:
<class name="Review`1[Person]" table="Review">
<id name="Id" column="ReviewId"><generator class="native" /></id>
<property name="Rating" />
<many-to-one name="Subject" column="PersonId" class="Person" />
</class>
The corresponding general class is as follows:
public class Review<T> : BaseEntity where T : IReviewable
{
public virtual int Rating { get; set; }
public virtual T Subject { get; set; }
}
, Review MVC- . , Subject , .
Review Person . , :
<class name="Person">
<bag name="Reviews" table="Review">
<key column="PersonId"/>
<one-to-many class="Review`1[Person]" />
</bag>
</class>
() :
public class Person : BaseEntity, IReviewable
{
public virtual IList<Review<Person>> Reviews { get; set; }
}
SessionFactory:
:.... --. class ....
, : ? ? ?