views:

266

answers:

1

Hi all,

I have an entity called User which can have a list of other Users called Friends (kinda like Facebook).

In my User entity, I've delcared a public virtual IList Friends { get; private set;} property, and an creating the list in the constructor. I also have an "AddFriends" method that adds Users to the Friends list.

In my UserMapping class I have the following code to map the relationship

HasManyToMany(x => x.Friends) 
                .ParentKeyColumn("UserId")
                .ChildKeyColumn("FriendId")
                .Table("UserFriends")
                .Inverse().Cascade.SaveUpdate().Not.LazyLoad();

All the tables get created correctly but nothing ever gets put in the UserFriends table and every user that comes back has an empty Friends list.

Any advice?

Thanks!

+2  A: 

Remove Inverse() call

maciejkow
That did it! Thanks!
James Bender

related questions