I have entity which has many data sources.
public class MyData
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual IList<DataSource> Sources { get; set; }
public MyData(){
Sources = new List<DataSource>();
}
}
and I have DataSource class which represents value object of MyData entity
public class DataSource
{
public enum SourceEnum { dataOneSrc = 1, dataTwoSrc = 2}
public virtual SourceEnum Source { get; set; }
public virtual string InternalRefNr { get; set; }
}
I'm using nhibernate orm and its mapping by code approach. So I mapped value object using this link as ref. //http://lycog.com/programming/nhibernate-32-mapping-code-component-mapping/
public static Action<IComponentMapper<DataSource>> Mapping()
{
return c =>{
c.Property(p => p.Source);
c.Property(p => p.InternalRefNr, m =>
{
m.Length(255);
});
};
}
and entity mapping using
public MyData()
{
...
Bag<DataSource>(x => x.Sources,
c => { },
r =>{ r.OneToMany();}
);
}
I'm getting Nhibernate.MappingException
{"Association references unmapped class: My.Model.DataSource"}
DataSource
as well. That's it - Radim Köhler