I have a database (which cannot be changed) with a whole load of values that are stored in two columns:
Currently each column is mapped to one property and my Domain object looks like this:
int? Value1
bool IsValue1RealValue
string Value2
bool IsValue2RealValue
bool? Value3
bool IsValue3RealValue
I want to put those into a ValueType which would hold 2 or 3 values:
-The value (stored in object or in T)
-The boolean 'RealValue'
-And (optionally) the name of the .NET property name
At the moment I have the following NHibernate mapping:
Component(x => x.Value1, fdf =>
{
fdf.Map(f => f.Value).Column("Value1");
fdf.Map(f => f.IsRealValue).Column("IsValue1RealValue");
});
Value1 has the following type:
public class FlaggedNullableIntValue
{
public int? Value;
public bool IsRealValue;
}
My domain object would then look like:
public class DomainEntity
{
public virtual FlaggedNullableIntValue Value1;
public virtual FlaggedStringValue Value2;
public virtual FlaggedNullableBooleanValue Value3;
}
I wonder if it is a good idea to go further down this road or is there another construct that might better suit my needs?
Torobjectsif the the type ofValueisint?? What property name do you want to map?limitationof NHibernate (if that is a limitation)ICompositeUserType.