I'm trying To map object field in fluent-Nhibernate and C#,the model contain an entity which has a reference field to a ValueObject
,
this is the entity class
public class QueryLeaf : Entity
{
public QueryLeaf()
{
FilterDescriptors = new List<FilterDescriptor>();
}
public virtual int Id { get; set; }
public virtual List<FilterDescriptor> FilterDescriptors { get; set; }
}
this is the value object class
[Serializable]
public class FilterDescriptor : ValueObject
{
public FilterOperator FilterOperator { get; set; }//this is an enum value
public object Value { get; set; }
}
and this is the mapping class
public sealed class QueryLeafMap : ClassMap<QueryLeaf>
{
public QueryLeafMap()
{
Id(x => x.Id);
HasMany(x => x.FilterDescriptors).Component(com =>
{
com.Map(y => y.FilterOperator);
com.Map(y => y.Value);
});
}
}
When running the above code the compiler stops on global.asax
page and give me this error
collection element mapping has wrong number of columns QueryLeaf.FilterDescriptors type: component[FilterOperator,Value]