You'd want to create a third class for your "Pivot" data. Such as
"UserMessages" or the like. It would contain something like this:
public class UserMessages
{
public virtual int Id {get;set;}
public virtual User User {get;set;}
public virtual Message Message {get;set;}
public virtual bool Deleted {get;set;}
}
Then map that as a HasMany() from both the User and the Message class. The
UserMessages would map back to the User and Message using a References(). Be
sure to set .Inverse() on the HasMany() mapping.
For more in depth examples, check into how people map an "Orderline" in an
Orders/Parts scenario.
On Tue, Jul 21, 2009 at 10:04 AM, Brian Kendig <[email protected]> wrote:
>
> I want to let users of my application send messages to each other. I
> also want to let a user remove messages from his Inbox, but naturally
> I can't delete the actual message when he does this (because then it
> would disappear from everyone else's inboxes as well), so I want to
> know how to store additional information in the pivot table,
>
> I've got a Users table and a Messages table, and a
> MessageRecipientsPivot table which stores each relationship between a
> message and a recipient. And in my UsersMappingOverride.cs file, I've
> got:
>
> mapping.HasManyToMany(x => x.Messages)
> .Cascade.All()
> .WithTableName("MessageRecipientsPivot")
> .WithParentKeyColumn("FkUser")
> .WithChildKeyColumn("FkMessage");
>
> I want to add a boolean Deleted column to this pivot table, so that
> when someone removes a message from his inbox, the Deleted value for
> that relationship row is set to true.
>
> How would I access this extra column in the pivot table?
>
>
> >
>
--
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---