Working on many 1-N relations between parts like order-orderdetail pricelist-price product-price, etc, I discovered what seems to be an incoherence in the way the orchard mapper is working.
Let's say I have an OderPartRecord and an OrderDetailPartRecord with corresponding OrderPart and OrderDetailParts.
in my OrderDetailPartRecord, I have a property
public virtual OrderPartRecord Order { get; set; }
in my migration file I simply define the Order_Id column as
SchemaBuilder.CreateTable("OrderDetailPartRecord", t => t
.ContentPartRecord()
.Column<int>("Order_Id")
and with this when I get my OrderDetail part with contenmanager, NHibernate automatically fills the contained OrderPartRecord using the Order_Id.
This is ok and the same schema work OK for many others 1-N
BUT
if in my OrderPartRecord class I defined this property
public virtual IList<OrderDetailPartRecord> Details { get; protected set; }
expecting Orchar+Nhibernate automatically filling the list when I get the OrderPart, it seems that the mapping created is trying to use a column named OrderPartRecord_Id, and not the Order_Id created to have the OrderPartRecord loaded in the OrderDetailPart object.
If I open the mappings.bin file (and regenerate it to be sure it is last version) I see that the 2 mappings are generated, one using Order_Id and the other OrderPartRecord_Id ????
Is there a problem of circular reference and should we use either the parent record in the child, either the list of child records in the Parent BUT NOT THE 2 SIMULTEOUSLY ?
This finally appeared to me as a bug and I opened this ticket.