Nhibernate, Need help to build entity class

8 views
Skip to first unread message

feelexit

unread,
Dec 28, 2011, 2:11:12 PM12/28/11
to nhibernate-development
I have 3 tables, they are very simple. User, Post, Favorite.


User Table:
Id: int
Name: string
--------------------------------

Post Table:
Id: int
Title: string
UserId: int (this is the FK)
--------------------------------

Favorite Table:
UserId: int
PostId: int
--------------------------------

I create 2 class files for User and Post tables. Dont know how to add
Favorite table there, Favorite table allows User to bookmark their
favorite posts.



public class User : Entity
{
public User() { this.Posts = new List<Post>;}
public virtual string Name { get; set; }
public virtual IList<Post> Posts {get; set;}
}

public class Post : Entity
{
public Post() {}
public virtual string Title { get; set; }
public virtual User User { get; set; }
}


Stephen Bohlen

unread,
Dec 28, 2011, 2:34:58 PM12/28/11
to nhibernate-...@googlegroups.com
Please direct user questions to the appropriate group at http://groups.google.com/group/nhusers

This mailing list is for discussions about the development of the NH codebase itself.

Steve Bohlen
sbo...@gmail.com
http://blog.unhandled-exceptions.com
http://twitter.com/sbohlen
Reply all
Reply to author
Forward
0 new messages