使用Automapper在MVC中编辑post方法 [英] post method for edit in MVC using Automapper
本文介绍了使用Automapper在MVC中编辑post方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
编辑未保存然后更改MVC4 Automapper
以下是我的代码..
Edit is not saving then changes in MVC4 Automapper
Below is my code..
public ActionResult Edit(int id, User userDetails)//
{
try
{
var dbContext = new MyDBDataContext();
Mapper.CreateMap<learningmvc.user,>();
var user = Mapper.Map<learningmvc.user,learningmvc.models.user>(userDetails);
dbContext.SubmitChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
推荐答案
您好,
您的CreateMap缺少目的地类。另外,请检查两个类中属性的名称是否同步。
Hi,
Your CreateMap is missing destination class. Also please check the names of properties are in sync in both the classes.
这篇关于使用Automapper在MVC中编辑post方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文