Reputation: 1
I have 2 classes, MasterItem and ItemUOM. ItemUOM is a view that i've mapped and MasterItem a straight forward table. Is it possible to reference MasterItem in ItemUOM.
ItemUOM class:
public class ItemUOM : EntityBase<ItemUOM>
{
public virtual string ItemAlias { get; set; }
public virtual string Code { get; set; }
public virtual string UOM { get; set; }
public virtual decimal PackSize { get; set; }
public virtual long MasterItemID { get; set; }
**public virtual DomainEntities.MasterItem MasterItem { get; set; }**
}
ItemUOM mapping
public ItemUOMMapping()
{
Table("View_ItemUOM");
Id(x => x.ID);
Map(x => x.Code);
Map(x => x.ItemAlias);
Map(x => x.UOM);
Map(x => x.PackSize);
}
How can I reference to class "MasterItem".
Thanks Francois
Upvotes: 0
Views: 117
Reputation: 17350
Looks you need a regular many-to-one:
public ItemUOMMapping()
{
Table("View_ItemUOM");
Id(x => x.ID);
Map(x => x.Code);
Map(x => x.ItemAlias);
Map(x => x.UOM);
Map(x => x.PackSize);
References(x => x.MasterItem)
.Column("MasterItemID");
}
And MasterItem should have its own mapping where you specify all its properties.
Upvotes: 0
Reputation: 52745
You need to remove MasterItemID and use References(x => x.MasterItem)
, etc.
Upvotes: 1