So, I have two tables, name them User and Item. I want every user to be able to mark (for example, "watch" things in a Google universe) on any element.
Now, from a set-theoretical perspective, it makes sense to keep this as a simple connection between users and elements. Call this new table UserItemFlags. The table should have two columns; one with foreign keys in the User table, the other with foreign keys in the Item table. If the user flag U points to element I, this is then represented by the presence of a row (U, I)in the UserItemFlags table.
Now my problem with expressing this in Fluent-NHibernate is this: I can't figure out what to do with the mapping Id. Ideally, I would not have an identifier, because there is nothing more than the presence or absence of this connection between the User and the Element. A natural consequence of this model is the inability to duplicate rows in a table. This is the desired function.
using FluentNHibernate.Mapping;
public class UserItemFlagsMapping : ClassMap<UserItemFlags>
{
public UserItemFlagsMapping()
{
References(x => x.User).Not.Nullable();
References(x => x.Item).Not.Nullable();
}
}
I would be happy for any pointers in the right direction, even if they require me to abandon Fluent for this particular case.
source
share