Here are the relevant snippets. This is the parent object:
public class Article
{
public virtual IList<ArticleRevision> Revisions { get; set; }
}
<list name="Revisions" cascade="all" inverse="true" table="ArticleRevision">
<cache usage="read-write" />
<key column="ArticleID" not-null="true" />
<index column="Number" type="int32" />
<one-to-many class="ArticleRevision" />
</list>
This is a child:
public class ArticleRevision
{
public virtual Article Article { get; set; }
}
<many-to-one name="Article" column="ArticleID" not-null="true" />
Now I create an instance Article, add one collection ArticleRevisionto Article.Revisions, set the ArticleRevision.Articlereference to the instance, Articleand paste it into the database:
INSERT
INTO
ArticleRevision
(Content, Keywords, CreatedAt, SiteID, ArticleID, CreatedByUserID, ID)
VALUES
(@p0, @p1, @p2, @p3, @p4, @p5, @p6);
There is no column Number.
How to match a one-to-many bidirectional collection with list semantics in NHibernate?
source
share