如何映射到EditModel命令消息? [英] How to map EditModel to Command Messages?

查看:143
本文介绍了如何映射到EditModel命令消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

吉米·博加德洛杉矶精工程师<一个href=\"http://www.lostechies.com/blogs/jimmy%5Fbogard/archive/2009/09/17/the-case-for-two-way-mapping-in-automapper.aspx\"相对=nofollow>说,他自己的映射到EditModel命令消息的而不是映射到EditModel的DomainModel。任何人都可以再解释一下吗?

Jimmy Bogard at Los Techies says that he maps his EditModel to Command Messages instead of mapping EditModel to DomainModel. Can anyone explain this further?

推荐答案

我想这会是的命令模式执行基于所提供的信息相关的域对象的必要操作。例如类似

I'd guess it'd be a version of the command pattern that performs the necessary manipulations on the relevant domain objects based on the supplied message. e.g. Something like

public PromoteEmployeeCommand : ICommand {
     private readonly PromotionMessage _message;
     private readonly IEmployeeRepository _repository;

     public PromoteEmployeeCommand(PromotionMessage message,
                                   IEmployeeRepository repository) {
          _message = message;
          _repository = repository;
     }

     public void Execute() {
          /* Get the employee, give them a rise etc... */
     }
}

从编辑模型的映射可以解决了一些命令的消息可能被用来作为必需的(例如给员工的上升,通知他们的经理,增加对工资等的说明)。

The mapping from the edit model would resolve to a number of command messages that could be invoked as required (e.g. Give employee a rise, notify their manager, add a note for payroll etc).

该方法的优点是它可以通过编辑模型暴露任何$​​ P $ psentational担忧隔离你的域模型。

The advantage of this approach is that it can isolate your domain model from any presentational concerns exposed by the Edit model.

这篇关于如何映射到EditModel命令消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆