映射继承的实体
我使用 Fluent Nhibernate(很高兴),但在映射某些实体时遇到一些麻烦:
public enum AdverticeType { None,Image,Flash,Script}
public class Advertice
{
public virtual int ID { get;set;}
public virtual string Name { get;set;}
public virtual AdverticeType AdverticeType { get;set;}
}
public class ImageAdvertice : Advertice
{
public virtual int ID { get;set;}
public virtual string Path { get;set;}
public virtual string URL { get;set;}
}
public class ScriptAdvertice : Advertice
{
public virtual int ID { get;set;}
public virtual string Code { get;set;}
}
How do i map toEntity so the ID in ScriptAdvertice is generated by ID in Advertice.
Im using Fluent Nhibernate(with pleasure) but have some trouble mapping some entities:
public enum AdverticeType { None,Image,Flash,Script}
public class Advertice
{
public virtual int ID { get;set;}
public virtual string Name { get;set;}
public virtual AdverticeType AdverticeType { get;set;}
}
public class ImageAdvertice : Advertice
{
public virtual int ID { get;set;}
public virtual string Path { get;set;}
public virtual string URL { get;set;}
}
public class ScriptAdvertice : Advertice
{
public virtual int ID { get;set;}
public virtual string Code { get;set;}
}
How do i map to entities so the ID in ScriptAdvertice is generated by ID in Advertice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
ClassMap
映射Advertice
,使用SubclassMap
映射ImageAdvertice
和ScriptAdvertice
。例如
Map
Advertice
using aClassMap
, andImageAdvertice
andScriptAdvertice
using aSubclassMap
.e.g.