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.
Right now the only other solution I can think of is to wrap each return statement in my UserService class to assign the user level before returning the user, which isn't a solution I want to continue t ouse.
public User Find(long valueA)
{
// Get the user
return AssignUserLevel(user);
}
public User AssignUserLevel(User user)
{
// set the user level of the user
}