I have poco class
public class Category : Entity<int>
{
public virtual Category Parent;
public virtual Iesi.Collections.Generic.ISet<Article> Articles {get; set;}
public virtual Iesi.Collections.Generic.ISet<Category> ChildCategories {get; set;}
}
I'm not sure is this correct mapping for ChildCategories property
public class CategoryMap : ClassMapping<Category>
{
public CategoryMap()
{
...
Set(x => x.ChildCategories,
c => { c.Cascade(Cascade.DeleteOrphans); },
r => { r.OneToMany(); }
);
}
}
Any child category can have only one parent. Once more is this correct mapping? If you need more information please ask.
Update: Exception inner message is following
{"Could not determine type for: xxxx,
for columns: NHibernate.Mapping.Column(Parent)"}
Update 2:
public class CategoryMap : ClassMapping<Category>
{
public CategoryMap()
{
Id(x => x.Id, m => m.Generator(Generators.GuidComb));
Property(x => x.Name, m =>
{
m.Length(255);
m.NotNullable(true);
});
Property(x => x.Parent, m =>
{
//m.NotNullable(true);
});
Set(x => x.ChildCategories,
c =>
{
c.BatchSize(25);
c.Inverse(true);
c.Cascade(Cascade.DeleteOrphans);
c.Key(k =>
{
k.Column("ParentId");
});
},
r => { r.OneToMany(); }
);
Set(x => x.Articles,
c => { c.Cascade(Cascade.DeleteOrphans); },
r => { r.OneToMany(); }
);
}
}
Update 3
Property(x => x.Parent, m =>
{
m.Column("ParentId");
m.NotNullable(true);
});
Error
{"Could not determine type for: xxxx,
for columns: NHibernate.Mapping.Column(ParentId)"}