Question

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!

Was it helpful?

Solution

Remove Inverse() call

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top