Below is a class model and an Oracle schema that I would like to map it to using Fluent NHibernate.
public enum EnumA { Type1, Type2, Type3 };
public class ClassB
{
public virtual string Property1 { get; set; }
public virtual string Property2 { get; set; }
}
public class ClassA
{
public virtual int ID { get; set; }
public virtual string Name { get; set; }
public virtual IDictionary<EnumA, IList<ClassB>> MyDictionary { get; set; }
}
TableA (NUMBER(38) ID PK, VARCHAR2(255) Name)
TableB (NUMBER(38) ID PK FK, NUMBER(38) Type PK, VARCHAR(255) Prop1, VARCHAR(255) Prop2)
How should I define the Fluent NHibernate mapping class?
I don't mind introducing a new domain class if necessary. I have tried the following:
public class ClassB
{
public virtual string Property1 { get; set; }
public virtual string Property2 { get; set; }
}
public class classC
{
public virtual EnumA EnumA { get; set; }
IList<ClassB> ClassBList { get; set; }
}
public class ClassA
{
public virtual int ID { get; set; }
public virtual string Name { get; set; }
public virtual IDictionary<EnumA, classC> MyDictionary { get; set; }
}
with the following mapping class
public ClassAMap()
{
WithTable("ClassA");
Id(x => x.ID);
Map(x => x.Name);
HasMany(x => x.MyDictionary).AsMap<EnumA>(d => d.EnumA).Component(c =>
{
c.HasMany(e => e.ClassBList).Component(f =>
{
f.Map(x => x.Property1);
f.Map(x => x.Property1);
});
});
}
However, this does not generate a valid configuration. Can anybody help?