tbf/Results/Mappings/PurchaseBoxMap.cs

28 lines
954 B
C#
Raw Permalink Normal View History

using FluentNHibernate.Mapping;
using Results.Entities;
namespace Results.Mappings
{
public class PurchaseBoxMap : ClassMap<PurchaseBox>
{
public PurchaseBoxMap()
{
Table("purchase_boxdata");
Id(x => x.Id);
Map(x => x.BoxNo);
// Map the foreign key to PurchaseOrder correctly
References(x => x.PurchaseOrder)
.Column("PurchaseOrderId") // Replace this with the correct column name
.Not.Nullable();
HasMany(x => x.PurchaseWaterMeterDataList)
.Cascade.All()
.KeyColumn("PurchaseBoxId") // This should match the foreign key in `purchase_boxdata`
.Inverse() // This is important if `PurchaseBox` holds the foreign key
.LazyLoad(); // Optional: Depends on your performance needs
}
}
}