In Fluent NHibernate, how would I map the following domain models?
- by Brandon
I have a user class that looks something like this
public class User
{
public virtual int Id { get; set; }
public virtual long ValueA { get; set; }
public virtual int? ValueB { get; set; }
}
ValueA is automatically assigned by the system. It is used in a lookup that would map to UserClass. However, if a value for ValueB exists, then it would do the lookup for UserClass in a different way.
Right now the way I handle it is to get the User and then perform a separate lookup each time.
return user.ValueB.HasValue ? Find(user.ValueB.Value) : Find(user.ValueA);
Is there any way to make Fluent NHibernate do this for me so I can have UserClass as a property on the User class instead of having to do the lookup separately? I was thinking of the ComponentMap but I'm not sure how to make it account for the two possible lookup values.