在投影中重用组件(NHibernate)
是否可以在投影中重用组件映射?
以下是供应商实体的映射:
<class name="Vendor" table="vendor">
...
<property name="Name" column="Name" />
<component name="Address" class="MyProject.Address, MyAssembly" >
<property name="Street" column="street" />
<property name="City" column="City" />
</component>
</class>
对于报告,我想在数据传输对象中检索这些供应商,但重用地址组件(因为有许多字段和一些有用的格式化行为)。
public class VendorDTO
{
public string Name;
public Address Address;
}
public class Address
{
public string Street;
public string City;
public string SomeUsefulBehavour();
}
如果不将地址拆分到它自己的表中,这可能吗?
谢谢!
Is it possible to reuse a component mapping in a projection?
Here is the mapping for the Vendor entity:
<class name="Vendor" table="vendor">
...
<property name="Name" column="Name" />
<component name="Address" class="MyProject.Address, MyAssembly" >
<property name="Street" column="street" />
<property name="City" column="City" />
</component>
</class>
For a report I'd like to retrieve these vendors in a data transfer object but reuse the Address component (because there are many fields and some useful formatting behavour).
public class VendorDTO
{
public string Name;
public Address Address;
}
public class Address
{
public string Street;
public string City;
public string SomeUsefulBehavour();
}
Is this possible without splitting Address out into it's own table?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这应该“有效”:
I believe this should 'just work':