[英]Fluent Nhibernate Mapping
I have 2 classes, MasterItem and ItemUOM. 我有2个类,MasterItem和ItemUOM。 ItemUOM is a view that i've mapped and MasterItem a straight forward table.
ItemUOM是我已映射的视图,而MasterItem是直接表。 Is it possible to reference MasterItem in ItemUOM.
是否可以在ItemUOM中引用MasterItem。
ItemUOM class: ItemUOM类:
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 ItemUOM映射
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". 如何引用类“ MasterItem”。
Thanks Francois 谢谢弗朗索瓦
您需要删除 MasterItemID并使用References(x => x.MasterItem)
等。
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. MasterItem应该具有自己的映射,您可以在其中指定其所有属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.