如何将实体转化为复合dto? (流利的休眠)
我在探索 Nhibernate 时遇到了一个问题。
我有以下实体。
以及它们对应的 Dto
现在使用以下查询,我尝试将 Orders 转换为 Orderdto
select o
FROM Order o
join o.OrderItems
join o.Customer
以下转换不起作用,可能是因为 Order 是复合类型。
var query = session.GetNamedQuery("GetOrderSummaries")
.SetResultTransformer(Transformers.AliasToBean<OrderItemDto>());
对于这种情况有任何开箱即用的转换吗?
I was exploring Nhibernate and have come across a problem.
I have the following Entities.
And the corresponding Dto for them
Now using the following query I am trying transform the Orders into Orderdto
select o
FROM Order o
join o.OrderItems
join o.Customer
The following transformation is not working probably because of Order being a composite type.
var query = session.GetNamedQuery("GetOrderSummaries")
.SetResultTransformer(Transformers.AliasToBean<OrderItemDto>());
Any out of box transformation available for such situations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我个人而言,我会使用 AutoMapper 来完成此任务,而不是在 Nhibernate/Fluent 中进行(无论是否可能) 。
Personally I would use AutoMapper for this, rather than doing it in Nhibernate/Fluent (whether or not it was possible).