取消映射父子子类映射中继承的子属性
是否可以取消映射从 Fluent Nhibernate 中为单独表设置的父子子类映射继承的属性?
类
public class Parent
{
public int Id { get; set; }
public string Name { get; set; }
public int ParentOnlyProperty { get; set; }
}
public class Child : Parent
{
public string AnotherProperty { get; set; }
}
映射
public class ParentMap : ClassMap<Parent>
{
public ParentMap()
{
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.ParentOnlyProperty);
}
}
public class ChildMap : SubclassMap<Child>
{
public ChildMap()
{
Map(x => x.AnotherProperty);
Unmap(x => x.ParentOnlyProperty); // is something like this possible?
}
}
Is it possible to unmap a property inherited from a parent-child subclass mapping in Fluent Nhibernate set up for separate tables?
Classes
public class Parent
{
public int Id { get; set; }
public string Name { get; set; }
public int ParentOnlyProperty { get; set; }
}
public class Child : Parent
{
public string AnotherProperty { get; set; }
}
Mappings
public class ParentMap : ClassMap<Parent>
{
public ParentMap()
{
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.ParentOnlyProperty);
}
}
public class ChildMap : SubclassMap<Child>
{
public ChildMap()
{
Map(x => x.AnotherProperty);
Unmap(x => x.ParentOnlyProperty); // is something like this possible?
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现我真的想在两个实体之间共享一些共同的属性,而不是子类化。以下问题的答案讨论了 BaseObjectMap:
Fluent Nhibernate 如何在SubclassMap中指定Id()
I figured out I really want to share some common properties between two entities, not subclassing. The following question's answer talks about a BaseObjectMap:
Fluent Nhibernate How to specify Id() in SubclassMap