- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 ASP.NET MVC 项目中,我们使用 AutoMapper 从域模型映射到 View 模型 - 有时还会在这样做的同时展平层次结构。这就像一个魅力,使我们的 View 的渲染逻辑非常精简和简单。
当我们想从 viewmodel(或 postmodel 或 editmodel)转到域模型时,困惑就开始了,尤其是在更新对象时 .我们不能使用自动/双向映射,因为:
ChangeManagerForEmployee()
”之类的方法或类似的方法。 From EditModel to CommandMessages – going from the loosely-typed EditModel to strongly-typed, broken out messages. A single EditModel might generate a half-dozen messages.
We use abstract mappers and services to map a PostModel to a Domain Object
UpdateModel()
将 FormCollection 合并到 viewModelUpdated 中最佳答案
我使用以下模式:
[HttpPost]
public ActionResult Update(UpdateProductViewModel viewModel)
{
// fetch the domain model that we want to update
Product product = repository.Get(viewModel.Id);
// Use AutoMapper to update only the properties of this domain model
// that are also part of the view model and leave the other properties unchanged
AutoMapper.Map<UpdateProductViewModel, Product>(viewModel, product);
// Pass the domain model with updated properties to the DAL
repository.Update(product);
return RedirectToAction("Success");
}
关于asp.net-mvc - 如何将editmodel/postmodel突变为域模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11313822/
Los Techies 的 Jimmy Bogard says that he maps his EditModel to Command Messages而不是将 EditModel 映射到 Dom
在 ASP.NET MVC 应用程序中创建 EditMoels 和更新数据时,我正在寻找一些最佳实践。假设我有一个这样的网址/Post/Edit?Id=25 我确保用户有权在 Get 请求上按 Id
一个简单的问题:是否有将 ASP.NET MVC 与 ORM、ViewModels 和 EditModels(最好使用 Automapper)一起使用的良好引用实现? 我了解使用这些特定目的模型的好处
我正在使用 AutoMapper 为 ViewModel 和 EditModel 创建 DTO。我找不到一个很好的例子来说明如何使用 EditModel 并将它包含的更改应用到数据库。 我首先考虑使用
我是一名优秀的程序员,十分优秀!