Skip to content

Instantly share code, notes, and snippets.

@scottwater

scottwater/Post.cs

Created Feb 7, 2010
Embed
What would you like to do?
public class Post
{
public virtual int Id { get; set; }
public virtual string Title { get; set; }
public virtual string Body { get; set; }
public virtual DateTime PubDate { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="..."
namespace="...">
<class name="Post" table="Posts" >
<id name="Id">
<generator class="identity"/>
</id>
<property name="Title" not-null="true" length="256"/>
<property name="Body" not-null="true"/>
<property name="PubDate" not-null="true"/>
<set name="Tags" table="Tags" inverse="true" cascade="all-delete-orphan">
<key column="PostId" />
<one-to-many class="Tag" />
</set>
</class>
</hibernate-mapping>
public class Tag
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual Post Parent { get; set; }
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="..."
namespace="...">
<class name="Tag" table="Tags" >
<id name="Id">
<generator class="identity"/>
</id>
<property name="Name" not-null="true" length="64"/>
<many-to-one name="Parent" column="PostId" not-null="true"/>
<!--
<set name="Posts" table="Posts" >
<key column="Id"></key>
<many-to-many class="Post" column="Id"></many-to-many>
</set>
-->
</class>
</hibernate-mapping>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.