AutoMapper 扁平化了领域模型,但它的作用相反吗? 如果不是,那是什么?
我一直在阅读 AutoMapper,因为我之前的一个问题得到了答复 这里。
它说 AutoMapper 会展平复杂的域模型,但我需要一些相反的功能。 我需要将视图模型(扁平域模型)连接到复杂的域模型,以便我可以快速将视图模型转换为域模型。
有没有类似于 AutoMapper 的东西,它采用视图模型并使其成为复杂的领域模型?
I've been reading up on AutoMapper because of a response to one of my earlier questions here.
It says that AutoMapper flattens complex domain models, but I need something that does the opposite. I need to wire up my view models (flattened domain models) to the complex domain models so that I can quickly transform a view model into a domain model.
Is there anything similar to AutoMapper that takes a view model and makes it into a complex domain model?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你做!。 您创建一个 MapToModel 方法,在其中执行右手/左手编码并将两者同步在一起。
如果应用程序能够自行编码,我们究竟会以什么为生......?
You do!. You create a MapToModel method where you do the right-hand/left-hand coding and sync the two together.
If applications coded themselves, what exactly would we do for a living...?
不一定,因为它必须非常传统才能有用。 展平时很容易辨别模式,但反过来……自定义逻辑太多了。
Not really, because it would have to be extremely conventional to be useful. It's easy to discern patterns when flattening, but the other way 'round... just too much custom logic.
非常容易使用:
ValueInjecter 可以做到这一点,而且
the ValueInjecter does it, and it's quite easy to use:
and